Re: Testing archetypes with Ant
I finally got everything working, but I'm also experiencing a strange side effect. The common-test.xml[1] script is called from each archetype's pom.xml: profiles profile idintegration-test/id activation property name!maven.test.skip/name /property /activation build plugins plugin artifactIdmaven-antrun-plugin/artifactId version1.1/version configuration tasks ant antfile=../common-test.xml dir=. property name=archetype value=${pom.artifactId}/ property name=version value=${pom.version}/ /ant /tasks /configuration executions execution phaseintegration-test/phase goals goalrun/goal /goals /execution /executions /plugin /plugins /build /profile /profiles However, there's something in these archetype tests that causes downstream antrun executions to fail. This no longer works: plugin artifactIdmaven-antrun-plugin/artifactId version1.1/version configuration tasks taskdef resource=webtest_base_relaxed.taskdef classpath refid=maven.test.classpath/ /taskdef AFAICT, the classpath is somehow getting messed up by the archetype Ant execution. If I comment out the archetype tests, the above taskdef works. Strangely enough, the archetype tests create archetypes and run integration tests with the same taskdef and it works fine. Do I need to fork the JVM or something to get this to work? Has anyone else experienced antrun executions causing issues with other antrun executions? Thanks, Matt [1] common-test.xml: ?xml version=1.0 encoding=UTF-8? !-- This file is imported in the archetype pom.xml files for integration tests -- project name=common-test default=test property name=version value=${version}/ property name=archetype value=${archetype}/ property name=test.dir value=${basedir}/target/test-archetype/ target name=test description=Tests that 'mvn integration-test' works with archetype echo message=Creating archetype '${archetype}', version '${version}'/ test archetype=${archetype} version=${version}/ /target macrodef name=test attribute name=archetype/ attribute name=version/ sequential delete dir=${test.dir}/ mkdir dir=${test.dir}/ maven dir=${basedir} command=install -Dmaven.test.skip=true/ maven dir=${test.dir} archetype=@{archetype} version=@{version} / maven dir=${test.dir}/archetype command=integration-test/ /sequential /macrodef macrodef name=maven attribute name=dir/ attribute name=name default=/ attribute name=archetype default=/ attribute name=version default=/ attribute name=command default=archetype:create -DarchetypeGroupId=org.appfuse [EMAIL PROTECTED] [EMAIL PROTECTED] -DgroupId=com.mycompany -DartifactId=archetype/ sequential exec dir=@{dir} executable=mvn.bat os=Windows XP failonerror=true arg line=@{command}/ /exec exec dir=@{dir} executable=mvn os=Mac OS X failonerror=true arg line=@{command}/ /exec exec dir=@{dir} executable=mvn os=Linux failonerror=true arg line=@{command}/ /exec /sequential /macrodef /project -- View this message in context: http://www.nabble.com/Testing-archetypes-with-Ant-tf3167091s177.html#a8810296 Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing archetypes with Ant
Hmmm, this might not work as good as I thought it did. It seems when the antrun plugin fails during integration testing, the antrun plugin running the tests doesn't catch and report the failure. Any idea how to fix this? [exec] [ERROR] BUILD ERROR [exec] [INFO] [exec] [INFO] Error executing ant tasks [exec] Embedded error: The following error occurred while executing this line: [exec] /Users/mraible/Work/appfuse-2.0/archetypes/appfuse-basic-spring/target/basicspring/src/test/resources/web-tests.xml:23: Canoo Webtest: R_1454. [exec] Test failed. [exec] Test step steps (/Users/mraible/Work/appfuse-2.0/archetypes/appfuse-basic-spring/target/basicspring/src/test/resources/web-tests.xml:25: ) null failed with message Step[invoke get Login Page (1/6)]: HTTP error 400, at: invoke [exec] [INFO] [exec] [INFO] For more information, run Maven with the -e switch [exec] [INFO] [exec] [INFO] Total time: 22 seconds [exec] [INFO] Finished at: Sat Feb 03 12:41:58 MST 2007 [exec] [INFO] Final Memory: 22M/508M [exec] [INFO] [exec] Result: 1 [INFO] Executed tasks [INFO] [install:install] [INFO] Installing /Users/mraible/Work/appfuse-2.0/archetypes/appfuse-basic-spring/target/appfuse-basic-spring-1.0-m3-SNAPSHOT.jar to /Users/mraible/.m2/repository/org/appfuse/appfuse-basic-spring/1.0-m3-SNAPSHOT/appfuse-basic-spring-1.0-m3-SNAPSHOT.jar [INFO] [INFO] BUILD SUCCESSFUL [INFO] [INFO] Total time: 29 seconds [INFO] Finished at: Sat Feb 03 12:41:58 MST 2007 [INFO] Final Memory: 8M/508M [INFO] Thanks, Matt mraible wrote: I've figured out a way to test archetypes with Ant, but it's not quite as clean as I'd like. In my archetypes directory, I have a common-test.xml[1] file that gets called from the archetype using the antrun-plugin: The following works: plugin artifactIdmaven-antrun-plugin/artifactId version1.1/version configuration tasks ant antfile=test.xml/ /tasks /configuration executions execution phaseintegration-test/phase goals goalrun/goal /goals /execution /executions /plugin If test.xml has: ?xml version=1.0 encoding=UTF-8? project name=integration-test basedir=. default=test !-- Import macrodefs for running Maven to create archetypes and run integration tests -- import file=../common-test.xml/ target name=test description=Tests that 'mvn integration-test' works with archetype test archetype=appfuse-basic-jsf name=basicjsf version=1.0-m3-SNAPSHOT/ /target /project Is it possible to move the contents from test.xml into the pom.xml itself? When I try to use the following, it fails with a NPE: tasks import file=../common-test.xml/ test archetype=appfuse-basic-jsf name=basicjsf version=1.0-m3-SNAPSHOT/ /tasks Error: Embedded error: java.lang.NullPointerException [INFO] [INFO] Trace org.apache.maven.lifecycle.LifecycleExecutionException: Error executing ant tasks at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:559) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:475) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:454) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322) at