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>
            <id>integration-test</id>
            <activation>
                <property>
                    <name>!maven.test.skip</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.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>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>run</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>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.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]

Reply via email to