Repository: maven-archetype Updated Branches: refs/heads/master dafa0d81c -> ac7c4f0ab
Allow execution of groovy script after archetype generation. Modify the FilesetArchetypeCreator to include a script with name META-INF/archetype-post-generate.groovy in the created archetype. Also execute this script in the DefaultFilesetArchetypeGenerator after the archetype has been created. This will allow defining of some post-generate logic (delete a file, rename a folder, etc.) after archetype generation. Close https://issues.apache.org/jira/browse/ARCHETYPE-494 Project: http://git-wip-us.apache.org/repos/asf/maven-archetype/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-archetype/commit/ac7c4f0a Tree: http://git-wip-us.apache.org/repos/asf/maven-archetype/tree/ac7c4f0a Diff: http://git-wip-us.apache.org/repos/asf/maven-archetype/diff/ac7c4f0a Branch: refs/heads/master Commit: ac7c4f0ab2e4078c0ea7879e043963c0dd7105f0 Parents: dafa0d8 Author: Petar Tahchiev <paranoia...@gmail.com> Authored: Thu Jan 7 10:04:40 2016 +0200 Committer: Petar Tahchiev <paranoia...@gmail.com> Committed: Sat Jan 9 12:48:03 2016 +0200 ---------------------------------------------------------------------- archetype-common/pom.xml | 28 +++++ .../common/ArchetypeArtifactManager.java | 2 + .../maven/archetype/common/Constants.java | 2 + .../common/DefaultArchetypeArtifactManager.java | 20 +++ .../creator/FilesetArchetypeCreator.java | 17 +++ .../DefaultFilesetArchetypeGenerator.java | 29 ++++- .../META-INF/archetype-post-generate.groovy | 6 + .../META-INF/maven/archetype-metadata.xml | 121 +++++++++++++++++++ .../archetypes/fileset_with_postscript/pom.xml | 27 +++++ .../archetype-resources/pom.xml | 38 ++++++ .../archetype-resources/profiles.xml | 13 ++ .../archetype-resources/src/main/java/App.java | 13 ++ .../archetype-resources/src/main/java/App.ogg | 13 ++ .../src/main/java/ToDelete.java | 1 + .../src/main/java/inner/package/App2.java | 13 ++ .../src/main/resources/App.properties | 13 ++ .../src/main/resources/__artifactId__/touch.txt | 13 ++ .../resources/__rootArtifactId__/touch_root.txt | 13 ++ .../src/main/resources/some-dir/App.png | 13 ++ .../archetype-resources/src/site/apt/usage.apt | 13 ++ .../archetype-resources/src/site/site.xml | 13 ++ .../archetype-resources/subproject/pom.xml | 44 +++++++ .../subproject/src/main/java/App.java | 13 ++ .../subproject/subsubproject/pom.xml | 40 ++++++ .../subsubproject/src/main/java/App.java | 13 ++ ...aryProperty-__property-with-default-1__.java | 14 +++ ...-property__-__property-with-default-2__.java | 14 +++ ...me__rootArtifactId__Class__artifactId__.java | 14 +++ .../DefaultArchetypeGeneratorTest.java | 85 +++++++++++++ 29 files changed, 656 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/pom.xml ---------------------------------------------------------------------- diff --git a/archetype-common/pom.xml b/archetype-common/pom.xml index a0b4efc..33d2ad4 100644 --- a/archetype-common/pom.xml +++ b/archetype-common/pom.xml @@ -164,6 +164,11 @@ <type>war</type> <scope>test</scope> </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy</artifactId> + <version>1.8.3</version> + </dependency> </dependencies> <build> @@ -361,7 +366,30 @@ <goal>run</goal> </goals> </execution> + <execution> + <id>archetype-test-fileset-with-postscript</id> + <phase>process-test-resources</phase> + <configuration> + <target> + <property name="test.archetype.name" value="fileset_with_postscript" /> + <property name="test.archetype.version" value="1.0" /> + + <property name="test.projects.repository" value="repositories/central" /> + <property name="test.archetype.name-version" value="${test.archetype.name}-${test.archetype.version}" /> + <property name="test.source.directory" value="${project.basedir}/src/test/archetypes/${test.archetype.name-version}" /> + <property name="test.target.directory" value="${project.build.directory}/test-classes/${test.projects.repository}/archetypes/${test.archetype.name}/${test.archetype.version}" /> + <mkdir dir="${test.target.directory}" /> + + <jar destfile="${test.target.directory}/${test.archetype.name-version}.jar" basedir="${test.source.directory}/" /> + + <copy tofile="${test.target.directory}/${test.archetype.name-version}.pom" file="${test.source.directory}/META-INF/maven/archetypes/${test.archetype.name}/pom.xml" /> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> <execution> <id>repository-metadata</id> <phase>process-test-resources</phase> http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/main/java/org/apache/maven/archetype/common/ArchetypeArtifactManager.java ---------------------------------------------------------------------- diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/common/ArchetypeArtifactManager.java b/archetype-common/src/main/java/org/apache/maven/archetype/common/ArchetypeArtifactManager.java index 529f0e3..5fdaab1 100644 --- a/archetype-common/src/main/java/org/apache/maven/archetype/common/ArchetypeArtifactManager.java +++ b/archetype-common/src/main/java/org/apache/maven/archetype/common/ArchetypeArtifactManager.java @@ -81,6 +81,8 @@ public interface ArchetypeArtifactManager ArtifactRepository archetypeRepository, ArtifactRepository localRepository, List<ArtifactRepository> repos ); + String getPostGenerationScript( File archetypeFile ) throws UnknownArchetype; + /** */ ArchetypeDescriptor getFileSetArchetypeDescriptor( File archetypeFile ) http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/main/java/org/apache/maven/archetype/common/Constants.java ---------------------------------------------------------------------- diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/common/Constants.java b/archetype-common/src/main/java/org/apache/maven/archetype/common/Constants.java index 9015c62..db5ce46 100644 --- a/archetype-common/src/main/java/org/apache/maven/archetype/common/Constants.java +++ b/archetype-common/src/main/java/org/apache/maven/archetype/common/Constants.java @@ -36,6 +36,8 @@ public interface Constants String ARCHETYPE_POST_GENERATION_GOALS = "archetype.goals"; + String ARCHETYPE_POST_GENERATION_SCRIPT = "META-INF/archetype-post-generate.groovy"; + String ARCHETYPE_POM = "pom.xml"; String ARCHETYPE_RESOURCES = "archetype-resources"; http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java ---------------------------------------------------------------------- diff --git a/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java b/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java index a3de790..6c35f18 100644 --- a/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java +++ b/archetype-common/src/main/java/org/apache/maven/archetype/common/DefaultArchetypeArtifactManager.java @@ -19,6 +19,7 @@ package org.apache.maven.archetype.common; * under the License. */ +import org.apache.commons.io.IOUtils; import org.apache.maven.archetype.downloader.DownloadException; import org.apache.maven.archetype.downloader.DownloadNotFoundException; import org.apache.maven.archetype.downloader.Downloader; @@ -299,6 +300,25 @@ public class DefaultArchetypeArtifactManager } } + public String getPostGenerationScript( File archetypeFile ) throws UnknownArchetype + { + ZipFile zipFile = null; + try + { + zipFile = getArchetypeZipFile( archetypeFile ); + Reader reader = getDescriptorReader( zipFile, Constants.ARCHETYPE_POST_GENERATION_SCRIPT ); + return reader == null ? null : IOUtils.toString( reader ); + } + catch ( IOException e ) + { + throw new UnknownArchetype( e ); + } + finally + { + closeZipFile( zipFile ); + } + } + public ArchetypeDescriptor getFileSetArchetypeDescriptor( File archetypeFile ) throws UnknownArchetype { http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/main/java/org/apache/maven/archetype/creator/FilesetArchetypeCreator.java ---------------------------------------------------------------------- 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 304a2a8..e755749 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 @@ -19,6 +19,7 @@ package org.apache.maven.archetype.creator; * under the License. */ +import org.apache.commons.collections.CollectionUtils; import org.apache.maven.archetype.ArchetypeCreationRequest; import org.apache.maven.archetype.ArchetypeCreationResult; import org.apache.maven.archetype.common.ArchetypeFilesResolver; @@ -147,6 +148,22 @@ public class FilesetArchetypeCreator File archetypeDescriptorFile = new File( archetypeResourcesDirectory, Constants.ARCHETYPE_DESCRIPTOR ); archetypeDescriptorFile.getParentFile().mkdirs(); + File archetypePostGenerationScript = + new File( archetypeResourcesDirectory, Constants.ARCHETYPE_POST_GENERATION_SCRIPT ); + archetypePostGenerationScript.getParentFile().mkdirs(); + + if ( request.getProject().getBuild() != null && CollectionUtils.isNotEmpty( + request.getProject().getBuild().getResources() ) ) + { + File inputFile = new File( + request.getProject().getBuild().getResources().get( 0 ).getDirectory() + File.separator + + Constants.ARCHETYPE_POST_GENERATION_SCRIPT ); + if ( inputFile.exists() ) + { + FileUtils.copyFile( inputFile, archetypePostGenerationScript ); + } + } + getLogger().debug( "Starting archetype's descriptor " + project.getArtifactId() ); ArchetypeDescriptor archetypeDescriptor = new ArchetypeDescriptor(); http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/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 7ebe3c8..154015f 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 @@ -19,6 +19,8 @@ package org.apache.maven.archetype.generator; * under the License. */ +import groovy.lang.Binding; +import groovy.lang.GroovyShell; import org.apache.maven.archetype.ArchetypeGenerationRequest; import org.apache.maven.archetype.common.ArchetypeArtifactManager; import org.apache.maven.archetype.common.ArchetypeFilesResolver; @@ -59,6 +61,7 @@ import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import java.util.ArrayList; +import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.regex.Pattern; @@ -204,12 +207,34 @@ public class DefaultFilesetArchetypeGenerator outputDirectoryFile, packageName, archetypeDescriptor, context ); } + String postGenerationScript = archetypeArtifactManager.getPostGenerationScript( archetypeFile ); + if ( postGenerationScript != null ) + { + getLogger().info( "Executing post-generation script" ); + Binding binding = new Binding(); + + if ( request.getProperties() != null ) + { + + request.getProperties().putAll( System.getProperties() ); + Enumeration e = request.getProperties().propertyNames(); + while ( e.hasMoreElements() ) + { + String key = (String) e.nextElement(); + binding.setVariable( key, request.getProperties().getProperty( key ) ); + } + } + + GroovyShell shell = new GroovyShell( binding ); + shell.evaluate( postGenerationScript ); + } + // ---------------------------------------------------------------------- // Log message on OldArchetype creation // ---------------------------------------------------------------------- if ( getLogger().isInfoEnabled() ) { - getLogger().info( "project created from Archetype in dir: " + outputDirectoryFile.getAbsolutePath() ); + getLogger().info( "Project created from Archetype in dir: " + outputDirectoryFile.getAbsolutePath() ); } } catch ( FileNotFoundException ex ) @@ -468,7 +493,7 @@ public class DefaultFilesetArchetypeGenerator if ( maybeVelocityExpression( value ) ) { - value = evaluateExpression( context, key, value ); + value = evaluateExpression( context, key, value ); } context.put( key, value ); http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/archetype-post-generate.groovy ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/archetype-post-generate.groovy b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/archetype-post-generate.groovy new file mode 100644 index 0000000..7b01980 --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/archetype-post-generate.groovy @@ -0,0 +1,6 @@ +println "Executing the post_create script..."; + +def projectFolder = this.'user.dir' + this.'file.separator' + "target/test-classes/projects" + this.'file.separator' + "generate-13" + this.'file.separator' + "file-value" + this.'file.separator'; + +println "Removing file: ${projectFolder}src/main/java/file/value/package/ToDelete.java"; +new File(projectFolder + "src/main/java/file/value/package/ToDelete.java").delete(); http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/maven/archetype-metadata.xml ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/maven/archetype-metadata.xml b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000..6b2523a --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,121 @@ +<?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 name="fileset" partial="false"> + + <requiredProperties> + <requiredProperty key="property-with-default-1"> + <defaultValue>default-value</defaultValue> + </requiredProperty> + <requiredProperty key="property-with-default-2"> + <defaultValue>default-value</defaultValue> + </requiredProperty> + <requiredProperty key="property-with-default-3"> + <defaultValue>default-value</defaultValue> + </requiredProperty> + <requiredProperty key="property-with-default-4"> + <defaultValue>default-value</defaultValue> + </requiredProperty> + <requiredProperty key="property-without-default-1"/> + <requiredProperty key="property-without-default-2"/> + <requiredProperty key="property-without-default-3"/> + <requiredProperty key="property-without-default-4"/> + </requiredProperties> + + <fileSets> + <fileSet filtered="true" packaged="true"> + <directory>src/main/java</directory> + <includes> + <include>**/*.java</include> + </includes> + </fileSet> + <fileSet filtered="false" packaged="true"> + <directory>src/main/java</directory> + <includes> + <include>**/*.ogg</include> + </includes> + </fileSet> + <fileSet filtered="true" packaged="false"> + <directory>src/main/resources</directory> + <includes> + <include>**/*.properties</include> + <include>**/*.txt</include> + </includes> + </fileSet> + <fileSet filtered="false" packaged="false"> + <directory>src/main/resources</directory> + <includes> + <include>**/*.png</include> + </includes> + </fileSet> + <fileSet filtered="true" packaged="false"> + <directory>src/site</directory> + <includes> + <include>**/*.xml</include> + <include>**/*.apt</include> + </includes> + </fileSet> + <fileSet filtered="true"> + <directory></directory> + <includes> + <include>.classpath</include> + <include>*.xml</include> + </includes> + </fileSet> + <fileSet filtered="false" packaged="false"> + <directory>src/main/toto</directory> + <includes> + <include>**/*</include> + </includes> + </fileSet> + </fileSets> + + <modules> + <module name="subproject" id="subproject" dir="subproject"> + <fileSets> + <fileSet filtered="true" packaged="true"> + <directory>src/main/java</directory> + <includes> + <include>**/*.java</include> + </includes> + </fileSet> + <fileSet filtered="true" packaged="false"> + <directory>src/main/toto</directory> + <includes> + <include>**/*</include> + </includes> + </fileSet> + </fileSets> + + <modules> + <module name="subsubproject" id="subsubproject" dir="subsubproject"> + <fileSets> + <fileSet filtered="true" packaged="true"> + <directory>src/main/java</directory> + <includes> + <include>**/*.java</include> + </includes> + </fileSet> + </fileSets> + </module> + </modules> + </module> + </modules> + +</archetype-descriptor> http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/maven/archetypes/fileset_with_postscript/pom.xml ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/maven/archetypes/fileset_with_postscript/pom.xml b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/maven/archetypes/fileset_with_postscript/pom.xml new file mode 100644 index 0000000..b7422de --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/META-INF/maven/archetypes/fileset_with_postscript/pom.xml @@ -0,0 +1,27 @@ +<?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>archetypes</groupId> + <artifactId>fileset</artifactId> + <version>1.0</version> +</project> http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/pom.xml ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/pom.xml b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/pom.xml new file mode 100644 index 0000000..6c34c7b --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/pom.xml @@ -0,0 +1,38 @@ +<?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> + + <name>Maven archetype Test</name> + <packaging>pom</packaging> + + <modules> + <module>subproject</module> + </modules> + +</project> http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/profiles.xml ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/profiles.xml b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/profiles.xml new file mode 100644 index 0000000..d34de6e --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/profiles.xml @@ -0,0 +1,13 @@ +groupId=${groupId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/App.java ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/App.java b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/App.java new file mode 100644 index 0000000..d34de6e --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/App.java @@ -0,0 +1,13 @@ +groupId=${groupId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/App.ogg ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/App.ogg b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/App.ogg new file mode 100644 index 0000000..d34de6e --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/App.ogg @@ -0,0 +1,13 @@ +groupId=${groupId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/ToDelete.java ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/ToDelete.java b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/ToDelete.java new file mode 100644 index 0000000..3c74a80 --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/ToDelete.java @@ -0,0 +1 @@ +This file must be deleted by the post-create script. http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/inner/package/App2.java ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/inner/package/App2.java b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/inner/package/App2.java new file mode 100644 index 0000000..d34de6e --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/java/inner/package/App2.java @@ -0,0 +1,13 @@ +groupId=${groupId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/App.properties ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/App.properties b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/App.properties new file mode 100644 index 0000000..d34de6e --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/App.properties @@ -0,0 +1,13 @@ +groupId=${groupId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/__artifactId__/touch.txt ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/__artifactId__/touch.txt b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/__artifactId__/touch.txt new file mode 100644 index 0000000..d34de6e --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/__artifactId__/touch.txt @@ -0,0 +1,13 @@ +groupId=${groupId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/__rootArtifactId__/touch_root.txt ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/__rootArtifactId__/touch_root.txt b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/__rootArtifactId__/touch_root.txt new file mode 100644 index 0000000..d34de6e --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/__rootArtifactId__/touch_root.txt @@ -0,0 +1,13 @@ +groupId=${groupId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/some-dir/App.png ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/some-dir/App.png b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/some-dir/App.png new file mode 100644 index 0000000..d34de6e --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/main/resources/some-dir/App.png @@ -0,0 +1,13 @@ +groupId=${groupId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/site/apt/usage.apt ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/site/apt/usage.apt b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/site/apt/usage.apt new file mode 100644 index 0000000..d34de6e --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/site/apt/usage.apt @@ -0,0 +1,13 @@ +groupId=${groupId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/site/site.xml ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/site/site.xml b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/site/site.xml new file mode 100644 index 0000000..d34de6e --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/src/site/site.xml @@ -0,0 +1,13 @@ +groupId=${groupId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/pom.xml ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/pom.xml b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/pom.xml new file mode 100644 index 0000000..f74a253 --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/pom.xml @@ -0,0 +1,44 @@ +<?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>${parentArtifactId}</artifactId> + <version>${version}</version> + </parent> + + <groupId>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + + <name>Maven archetype Test Subfolder</name> + <packaging>pom</packaging> + + <modules> + <module>subsubproject</module> + </modules> + +</project> http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/src/main/java/App.java ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/src/main/java/App.java b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/src/main/java/App.java new file mode 100644 index 0000000..d34de6e --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/src/main/java/App.java @@ -0,0 +1,13 @@ +groupId=${groupId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/pom.xml ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/pom.xml b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/pom.xml new file mode 100644 index 0000000..dfbf01b --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/pom.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. + --> +<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>${parentArtifactId}</artifactId> + <version>${version}</version> + </parent> + + <groupId>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + + <name>Maven archetype Test Subsubfolder</name> + <packaging>jar</packaging> + +</project> http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/App.java ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/App.java b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/App.java new file mode 100644 index 0000000..d34de6e --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/App.java @@ -0,0 +1,13 @@ +groupId=${groupId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/ArbitraryProperty-__property-with-default-1__.java ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/ArbitraryProperty-__property-with-default-1__.java b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/ArbitraryProperty-__property-with-default-1__.java new file mode 100644 index 0000000..c6837ac --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/ArbitraryProperty-__property-with-default-1__.java @@ -0,0 +1,14 @@ +groupId=${groupId} +rootArtifactId=${rootArtifactId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/SkipsUndefinedProperty-__undefined-property__-__property-with-default-2__.java ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/SkipsUndefinedProperty-__undefined-property__-__property-with-default-2__.java b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/SkipsUndefinedProperty-__undefined-property__-__property-with-default-2__.java new file mode 100644 index 0000000..c6837ac --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/SkipsUndefinedProperty-__undefined-property__-__property-with-default-2__.java @@ -0,0 +1,14 @@ +groupId=${groupId} +rootArtifactId=${rootArtifactId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/__rootArtifactId__/inner/__artifactId__/innest/Some__rootArtifactId__Class__artifactId__.java ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/__rootArtifactId__/inner/__artifactId__/innest/Some__rootArtifactId__Class__artifactId__.java b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/__rootArtifactId__/inner/__artifactId__/innest/Some__rootArtifactId__Class__artifactId__.java new file mode 100644 index 0000000..c6837ac --- /dev/null +++ b/archetype-common/src/test/archetypes/fileset_with_postscript-1.0/archetype-resources/subproject/subsubproject/src/main/java/__rootArtifactId__/inner/__artifactId__/innest/Some__rootArtifactId__Class__artifactId__.java @@ -0,0 +1,14 @@ +groupId=${groupId} +rootArtifactId=${rootArtifactId} +artifactId=${artifactId} +version=${version} +package=${package} +packageInPathFormat=${packageInPathFormat} +property-without-default-1=${property-without-default-1} +property-without-default-2=${property-without-default-2} +property-without-default-3=${property-without-default-3} +property-without-default-4=${property-without-default-4} +property-with-default-1=${property-with-default-1} +property-with-default-2=${property-with-default-2} +property-with-default-3=${property-with-default-3} +property-with-default-4=${property-with-default-4} http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/ac7c4f0a/archetype-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGeneratorTest.java ---------------------------------------------------------------------- diff --git a/archetype-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGeneratorTest.java b/archetype-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGeneratorTest.java index 284f80d..c74f8ea 100644 --- a/archetype-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGeneratorTest.java +++ b/archetype-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGeneratorTest.java @@ -57,6 +57,9 @@ public class DefaultArchetypeGeneratorTest private final static Archetype ARCHETYPE_OLD = new Archetype( "archetypes", "old", "1.0" ); + private final static Archetype ARCHETYPE_FILESET_WITH_POSTCREATE_SCRIPT = + new Archetype( "archetypes", "fileset_with_postscript", "1.0" ); + private final static Properties ADDITIONAL_PROPERTIES = new Properties(); static { @@ -421,6 +424,88 @@ public class DefaultArchetypeGeneratorTest && result.getCause().getMessage().endsWith( "Property property-without-default-4 is missing." ) ); } + public void testGenerateArchetypeWithPostScriptIncluded() + throws Exception + { + System.out.println( "testGenerateArchetypeWithPostScriptIncluded" ); + + ArchetypeGenerationRequest request = + createArchetypeGenerationRequest( "generate-13", ARCHETYPE_FILESET_WITH_POSTCREATE_SCRIPT ); + + File projectFile = new File( projectDirectory, "pom.xml" ); + + FileUtils.forceDelete( projectDirectory ); + + generateProjectFromArchetype( request ); + + assertTemplateContentGeneratedWithFileSetArchetype( "src/main/java/file/value/package/App.java", "file-value" ); + assertTemplateContentGeneratedWithFileSetArchetype( "src/main/java/file/value/package/inner/package/App2.java", + "file-value" ); + + assertTemplateCopiedWithFileSetArchetype( "src/main/java/file/value/package/App.ogg" ); + + File templateFile = new File( projectDirectory, "src/main/java/file/value/package/ToDelete.java" ); + assertFalse( templateFile.exists() ); + + assertTemplateContentGeneratedWithFileSetArchetype( "src/main/resources/App.properties", "file-value" ); + assertTemplateContentGeneratedWithFileSetArchetype( "src/main/resources/file-value/touch.txt", "file-value" ); + assertTemplateContentGeneratedWithFileSetArchetype( "src/main/resources/file-value/touch_root.txt", + "file-value" ); + + assertTemplateCopiedWithFileSetArchetype( "src/main/resources/some-dir/App.png" ); + + assertTemplateContentGeneratedWithFileSetArchetype( "src/site/site.xml", "file-value" ); + assertTemplateContentGeneratedWithFileSetArchetype( "src/site/apt/usage.apt", "file-value" ); + assertTemplateContentGeneratedWithFileSetArchetype( ".classpath", "file-value" ); + assertTemplateContentGeneratedWithFileSetArchetype( "profiles.xml", "file-value" ); + + Model model = readPom( projectFile ); + assertNull( model.getParent() ); + assertEquals( "file-value", model.getGroupId() ); + assertEquals( "file-value", model.getArtifactId() ); + assertEquals( "file-value", model.getVersion() ); + + assertTemplateContentGeneratedWithFileSetArchetype( "subproject/src/main/java/file/value/package/App.java", + "subproject" ); + + model = readPom( new File( projectDirectory, "subproject/pom.xml" ) ); + assertNotNull( model.getParent() ); + assertEquals( "file-value", model.getParent().getGroupId() ); + assertEquals( "file-value", model.getParent().getArtifactId() ); + assertEquals( "file-value", model.getParent().getVersion() ); + assertEquals( "file-value", model.getGroupId() ); + assertEquals( "subproject", model.getArtifactId() ); + assertEquals( "file-value", model.getVersion() ); + + assertTemplateContentGeneratedWithFileSetArchetype( + "subproject/subsubproject/src/main/java/file/value/package/App.java", "subsubproject" ); + + assertTemplateContentGeneratedWithFileSetArchetype( "subproject/subsubproject/src/main/java/file/value/package/" + + "file-value/inner/subsubproject/innest/Somefile-valueClasssubsubproject.java", + "subsubproject" ); + + assertTemplateContentGeneratedWithFileSetArchetype( "subproject/subsubproject/src/main/java/file/value/package/" + /* + "file-value/inner/subsubproject/innest/" + */ + + "ArbitraryProperty-file-value.java", + "subsubproject" ); + + // Test that undefined properties are safely ignored (and skipped) + assertTemplateContentGeneratedWithFileSetArchetype( "subproject/subsubproject/src/main/java/file/value/package/" + /* + "file-value/inner/subsubproject/innest/" + */ + + "SkipsUndefinedProperty-__undefined-property__-file-value.java", + "subsubproject" ); + + model = readPom( new File( projectDirectory, "subproject/subsubproject/pom.xml" ) ); + assertNotNull( model.getParent() ); + assertEquals( "file-value", model.getParent().getGroupId() ); + assertEquals( "subproject", model.getParent().getArtifactId() ); + assertEquals( "file-value", model.getParent().getVersion() ); + assertEquals( "file-value", model.getGroupId() ); + assertEquals( "subsubproject", model.getArtifactId() ); + assertEquals( "file-value", model.getVersion() ); + + } + protected void tearDown() throws Exception {