Good stuff Luke, thanks, I've been pondering what the best approach is for this myself.
Kalle On Thu, Feb 11, 2010 at 6:13 AM, Luke Patterson <lukewpatter...@gmail.com> wrote: > On Wed, Feb 10, 2010 at 5:37 PM, Max Spring <mspr...@cisco.com> wrote: >> What would be a good approach to test an archetype project? >> ... >> A minimal test would be to "instantiate" the archetype and to build the >> resulting project. > > Here's some cut-and-paste that I'm using: > > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-invoker-plugin</artifactId> > <executions> > <execution> > <id>integration-test</id> > <goals> > <goal>install</goal> > <goal>run</goal> > </goals> > </execution> > </executions> > <configuration> > <cloneProjectsTo>${project.build.directory}/it/projects</cloneProjectsTo> > <goals> > <goal>org.apache.maven.plugins:maven-archetype-plugin:generate</goal> > </goals> > <localRepositoryPath>${project.build.directory}/it/repo</localRepositoryPath> > <pomIncludes> > <pomInclude>*</pomInclude> > </pomIncludes> > <projectsDirectory>${basedir}/src/it/projects</projectsDirectory> > <properties> > <archetypeArtifactId>${project.artifactId}</archetypeArtifactId> > <archetypeGroupId>${project.groupId}</archetypeGroupId> > <archetypeRepository>local</archetypeRepository> > <archetypeVersion>${project.version}</archetypeVersion> > <goals>verify</goals> > <interactiveMode>false</interactiveMode> > </properties> > <streamLogs>true</streamLogs> > </configuration> > </plugin> > > > then, your archetype will be run during integration-test phase for all > subdirectories of <projectsDirectory>, a test.properties file will > contain the inputs to the archetype:generate goal, and the verify > phase will be run on each newly generated project > > to add a new test, add another directory under <projectsDirectory> > with a test.properties file > > ------------------------------------------ > e.g. > > src/it/projects/firsttest/test.properties with contents: > > groupId=com.foo > artifactId=firsttest > version=1.0.0 > package=com.foo.firsttest > > that will create a "firsttest" directory under > ${project.build.directory}/it/projects/firsttest with the stuff > generated by your archetype, and then run the verify phase on the > newly generated "com.foo.firsttest" project > ------------------------------------------ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@maven.apache.org For additional commands, e-mail: users-h...@maven.apache.org