This is an automated email from the ASF dual-hosted git repository. sjaranowski pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-archetype.git
The following commit(s) were added to refs/heads/master by this push: new 444324a3 - Fixed resource files without extension missing in create-from-project - Added integration test for resource file without extension 444324a3 is described below commit 444324a3da2beb3720046aff02272bbf8f102640 Author: Daniel Umstädter <daniel.umstaed...@possehl-secure.de> AuthorDate: Wed May 21 09:45:38 2025 +0200 - Fixed resource files without extension missing in create-from-project - Added integration test for resource file without extension --- .../archetype/creator/FilesetArchetypeCreator.java | 20 ++++++++++++- .../archetype.properties | 26 +++++++++++++++++ .../invoker.properties | 18 ++++++++++++ .../pom.xml | 34 ++++++++++++++++++++++ .../res/txt/filewithnoextension | 16 ++++++++++ .../verify.groovy | 22 ++++++++++++++ 6 files changed, 135 insertions(+), 1 deletion(-) diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java b/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java index e138f1bb..6a691794 100644 --- a/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java +++ b/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java @@ -1143,6 +1143,18 @@ public class FilesetArchetypeCreator implements ArchetypeCreator { return extensions; } + private Set<String> getExtensionlessFiles(List<String> files) { + Set<String> extensionlessFiles = new HashSet<>(); + + for (String file : files) { + if (FileUtils.extension(file).isEmpty()) { + extensionlessFiles.add(file); + } + } + + return extensionlessFiles; + } + private Map<String, List<String>> getGroupsMap(final List<String> files, final int level) { Map<String, List<String>> groups = new HashMap<>(); @@ -1613,12 +1625,18 @@ public class FilesetArchetypeCreator implements ArchetypeCreator { private FileSet getUnpackagedFileSet( final boolean filtered, final String group, final List<String> groupFiles, String defaultEncoding) { Set<String> extensions = getExtensions(groupFiles); + Set<String> extensionlessFiles = getExtensionlessFiles(groupFiles); List<String> includes = new ArrayList<>(); List<String> excludes = new ArrayList<>(); for (String extension : extensions) { - includes.add("**/*." + extension); + if (!extension.isEmpty()) { + includes.add("**/*." + extension); + } + } + for (String extensionlessFile : extensionlessFiles) { + includes.add("**/" + extensionlessFile); } return createFileSet(excludes, false, filtered, group, includes, defaultEncoding); diff --git a/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/archetype.properties b/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/archetype.properties new file mode 100644 index 00000000..48b74ab6 --- /dev/null +++ b/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/archetype.properties @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +archetype.groupId=org.codehaus.mojo.archetypes +archetype.artifactId=maven-archetype-test +archetype.version=1.0 +archetype.languages=csharp +groupId=org.apache.maven.archetype.test +artifactId=test +version=1.0-SNAPSHOT +package=archetype +excludePatterns=build.log,invoker.properties,verify.groovy diff --git a/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/invoker.properties b/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/invoker.properties new file mode 100644 index 00000000..97ce30ea --- /dev/null +++ b/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/invoker.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.goals = org.apache.maven.plugins:maven-archetype-plugin:${project.version}:create-from-project diff --git a/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/pom.xml b/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/pom.xml new file mode 100644 index 00000000..e1d4a5a6 --- /dev/null +++ b/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/pom.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<project + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.archetype.test</groupId> + <artifactId>include-resource-file-with-no-extension</artifactId> + <version>1.0-SNAPSHOT</version> + + <name>Maven archetype Test Include A Resource File With No Extension</name> + <packaging>pom</packaging> + +</project> diff --git a/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/res/txt/filewithnoextension b/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/res/txt/filewithnoextension new file mode 100644 index 00000000..287f9b1f --- /dev/null +++ b/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/res/txt/filewithnoextension @@ -0,0 +1,16 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. \ No newline at end of file diff --git a/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/verify.groovy b/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/verify.groovy new file mode 100644 index 00000000..248829f0 --- /dev/null +++ b/maven-archetype-plugin/src/it/projects/include-resource-file-with-no-extension/verify.groovy @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +def templateDir = new File(basedir, 'target/generated-sources/archetype/src/main/resources/archetype-resources') + +assert new File(templateDir, 'res/txt/filewithnoextension').exists()