Repository: maven-archetype Updated Branches: refs/heads/master 741f432b8 -> 8763512e7
[ARCHETYPE-241] Filtering of directory name same as filenames Project: http://git-wip-us.apache.org/repos/asf/maven-archetype/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-archetype/commit/8763512e Tree: http://git-wip-us.apache.org/repos/asf/maven-archetype/tree/8763512e Diff: http://git-wip-us.apache.org/repos/asf/maven-archetype/diff/8763512e Branch: refs/heads/master Commit: 8763512e7b13f360916c8f5ee02b068bcee987ab Parents: 741f432 Author: rfscholte <rfscho...@apache.org> Authored: Tue Jan 24 12:37:06 2017 +0100 Committer: rfscholte <rfscho...@apache.org> Committed: Tue Jan 24 12:37:06 2017 +0100 ---------------------------------------------------------------------- .../DefaultFilesetArchetypeGenerator.java | 24 ++++++---- .../archetype/pom.xml | 46 ++++++++++++++++++ .../META-INF/maven/archetype-metadata.xml | 40 ++++++++++++++++ .../__projectName__-test2/pom.xml | 33 +++++++++++++ .../src/main/java/Test-__projectName__.java | 1 + .../__rootArtifactId__-test1/pom.xml | 33 +++++++++++++ .../main/resources/archetype-resources/pom.xml | 36 ++++++++++++++ .../invoker.properties | 23 +++++++++ .../it/ARCHETYPE-241_filter-directory/pom.xml | 49 ++++++++++++++++++++ .../project.properties | 27 +++++++++++ .../verify.groovy | 21 +++++++++ pom.xml | 23 +++++---- 12 files changed, 334 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/8763512e/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java ---------------------------------------------------------------------- diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java b/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java index 1ce6c03..b21e1a0 100644 --- a/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java +++ b/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultFilesetArchetypeGenerator.java @@ -578,10 +578,11 @@ public class DefaultFilesetArchetypeGenerator return count; } - private void processFilesetModule( String rootArtifactId, String artifactId, final List<String> archetypeResources, - File pom, final ZipFile archetypeZipFile, String moduleOffset, File basedirPom, - File outputDirectoryFile, final String packageName, - final AbstractArchetypeDescriptor archetypeDescriptor, final Context context ) + private void processFilesetModule( final String rootArtifactId, final String artifactId, + final List<String> archetypeResources, File pom, final ZipFile archetypeZipFile, + String moduleOffset, File basedirPom, File outputDirectoryFile, + final String packageName, final AbstractArchetypeDescriptor archetypeDescriptor, + final Context context ) throws DocumentException, XmlPullParserException, ArchetypeGenerationFailure, InvalidPackaging, IOException, OutputFileExists { @@ -612,15 +613,18 @@ public class DefaultFilesetArchetypeGenerator { ModuleDescriptor project = subprojects.next(); - File moduleOutputDirectoryFile = new File( outputDirectoryFile, - StringUtils.replace( project.getDir(), "__rootArtifactId__", - rootArtifactId ) ); + String modulePath = StringUtils.replace( project.getDir(), "__rootArtifactId__", rootArtifactId ); + modulePath = replaceFilenameTokens( modulePath, context ); + + File moduleOutputDirectoryFile = new File( outputDirectoryFile, modulePath ); context.put( Constants.ARTIFACT_ID, StringUtils.replace( project.getId(), "${rootArtifactId}", rootArtifactId ) ); - - processFilesetModule( rootArtifactId, - StringUtils.replace( project.getDir(), "__rootArtifactId__", rootArtifactId ), + + String moduleArtifactId = StringUtils.replace( project.getDir(), "__rootArtifactId__", rootArtifactId ); + moduleArtifactId = replaceFilenameTokens( moduleArtifactId, context ); + + processFilesetModule( rootArtifactId, moduleArtifactId, archetypeResources, new File( moduleOutputDirectoryFile, Constants.ARCHETYPE_POM ), archetypeZipFile, ( StringUtils.isEmpty( moduleOffset ) ? "" : ( moduleOffset + "/" ) ) http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/8763512e/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/pom.xml ---------------------------------------------------------------------- diff --git a/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/pom.xml b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/pom.xml new file mode 100644 index 0000000..661c8bc --- /dev/null +++ b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/pom.xml @@ -0,0 +1,46 @@ +<!-- +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> + + <parent> + <groupId>org.apache.maven.plugins.archetype.its</groupId> + <artifactId>archetype241-parent</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <artifactId>archetype241-archetype</artifactId> + <packaging>maven-archetype</packaging> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-archetype-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <archetypeDirectory>src/main/resources</archetypeDirectory> + </configuration> + </plugin> + </plugins> + </build> + +</project> http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/8763512e/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml ---------------------------------------------------------------------- diff --git a/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000..c3e354d --- /dev/null +++ b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,40 @@ +<?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. +--> + +<archetype-descriptor xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" + name="ARCHETYPE-241"> + <requiredProperties> + <requiredProperty key="projectName"/> + </requiredProperties> + + <modules> + <module dir="__rootArtifactId__-test1" /> + <module dir="__projectName__-test2"> + <fileSets> + <fileSet filtered="true"> + <directory>src/main/java</directory> + </fileSet> + </fileSets> + </module> + </modules> +</archetype-descriptor> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/8763512e/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/pom.xml ---------------------------------------------------------------------- diff --git a/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/pom.xml b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/pom.xml new file mode 100644 index 0000000..05d0416 --- /dev/null +++ b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/pom.xml @@ -0,0 +1,33 @@ +<?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> + + <parent> + <groupId>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + </parent> + <artifactId>${projectName}-test2</artifactId> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/8763512e/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/src/main/java/Test-__projectName__.java ---------------------------------------------------------------------- diff --git a/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/src/main/java/Test-__projectName__.java b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/src/main/java/Test-__projectName__.java new file mode 100644 index 0000000..5f9fc75 --- /dev/null +++ b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__projectName__-test2/src/main/java/Test-__projectName__.java @@ -0,0 +1 @@ +"This is ${projectName}!" http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/8763512e/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__rootArtifactId__-test1/pom.xml ---------------------------------------------------------------------- diff --git a/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__rootArtifactId__-test1/pom.xml b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__rootArtifactId__-test1/pom.xml new file mode 100644 index 0000000..1cf27a3 --- /dev/null +++ b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/__rootArtifactId__-test1/pom.xml @@ -0,0 +1,33 @@ +<?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> + + <parent> + <groupId>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + </parent> + <artifactId>${rootArtifactId}-test1</artifactId> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/8763512e/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/pom.xml ---------------------------------------------------------------------- diff --git a/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/pom.xml b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000..93ebda4 --- /dev/null +++ b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/archetype/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,36 @@ +<?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>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + <packaging>pom</packaging> + + <modules> + <module>${rootArtifactId}-test1</module> + <module>${projectName}-test2</module> + </modules> + +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/8763512e/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/invoker.properties ---------------------------------------------------------------------- diff --git a/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/invoker.properties b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/invoker.properties new file mode 100644 index 0000000..aaa45c6 --- /dev/null +++ b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/invoker.properties @@ -0,0 +1,23 @@ +# 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.1 = install +invoker.project.1 = archetype + +invoker.goals.2 = org.apache.maven.plugins:maven-archetype-plugin:${project.version}:generate +invoker.systemPropertiesFile = project.properties + http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/8763512e/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/pom.xml ---------------------------------------------------------------------- diff --git a/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/pom.xml b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/pom.xml new file mode 100644 index 0000000..5e200d7 --- /dev/null +++ b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/pom.xml @@ -0,0 +1,49 @@ +<!-- +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.plugins.archetype.its</groupId> + <artifactId>archetype241-parent</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <build> + <extensions> + <extension> + <groupId>org.apache.maven.archetype</groupId> + <artifactId>archetype-packaging</artifactId> + <version>@project.version@</version> + </extension> + </extensions> + + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-archetype-plugin</artifactId> + <version>@project.version@</version> + </plugin> + </plugins> + </pluginManagement> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/8763512e/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/project.properties ---------------------------------------------------------------------- diff --git a/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/project.properties b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/project.properties new file mode 100644 index 0000000..9f8c91f --- /dev/null +++ b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/project.properties @@ -0,0 +1,27 @@ +# 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. + +archetypeGroupId=org.apache.maven.plugins.archetype.its +archetypeArtifactId=archetype241-archetype +archetypeVersion=1.0-SNAPSHOT + +groupId=com.company +artifactId=myArtifactId +version=1.0-SNAPSHOT +package=com.company.project + +projectName=myName http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/8763512e/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/verify.groovy ---------------------------------------------------------------------- diff --git a/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/verify.groovy b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/verify.groovy new file mode 100644 index 0000000..b66e954 --- /dev/null +++ b/maven-archetype-plugin/src/it/ARCHETYPE-241_filter-directory/verify.groovy @@ -0,0 +1,21 @@ +/* + * 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. + */ + +assert new File( basedir, "myArtifactId/myName-test2" ).exists() +assert false == new File( basedir, "myArtifactId/__projectName__-test2" ).exists() \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/8763512e/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 623b385..e3b500a 100644 --- a/pom.xml +++ b/pom.xml @@ -78,9 +78,6 @@ <netbeans.hint.useExternalMaven>true</netbeans.hint.useExternalMaven> <wagonVersion>2.8</wagonVersion> <maven.site.path>archetype-archives/archetype-LATEST</maven.site.path> - <javaVersion>5</javaVersion> - <maven.compiler.source>1.${javaVersion}</maven.compiler.source> - <maven.compiler.target>1.${javaVersion}</maven.compiler.target> </properties> <dependencyManagement> @@ -290,15 +287,17 @@ <exclude>.java-version</exclude> </excludes> </configuration> - <executions> - <execution> - <id>rat-check</id> - <goals> - <goal>check</goal> - </goals> - <phase>verify</phase> - </execution> - </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <dependencies> + <dependency> + <groupId>org.codehaus.mojo</groupId> + <artifactId>extra-enforcer-rules</artifactId> + <version>1.0-beta-6</version> + </dependency> + </dependencies> </plugin> </plugins> </build>