You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by mraible <ma...@raibledesigns.com> on 2007/05/31 21:00:50 UTC

Using Ant to test Maven Plugins

I'm using Ant to test a Maven Plugin (as well as archetypes). I tried using
Maven Embedder, but was unable to get it to execute some of my "extension"
plugins with version 2.0.4.  Now I'm having issues getting Ant to fail
properly when executing Maven fails.  I'm sure this is probably more of an
Ant question, but hopefully someone here can help.

In my build.xml, I have a macrodef to execute Maven on various platforms:

    <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 -DarchetypeArtifactId=@{archetype}
-DarchetypeVersion=@{version} -DgroupId=com.company -DartifactId=@{name}"/>

        <sequential>
            <exec dir="@{dir}" executable="mvn.bat" os="Windows XP"
failonerror="true" errorproperty="command.failed">
                <arg line="@{command}"/>
            </exec>
            <exec dir="@{dir}" executable="mvn" os="Mac OS X"
failonerror="true" errorproperty="command.failed">
                <arg line="@{command}"/>
            </exec>
            <exec dir="@{dir}" executable="mvn" os="Linux"
failonerror="true" errorproperty="command.failed">
                <arg line="@{command}"/>
            </exec>

        </sequential>
    </macrodef>

I have another macrodef that calls this one:

    <macrodef name="create-gen-basic">
        <attribute name="archetype"/>
        <attribute name="version" default="${version}"/>
        <attribute name="name"/>

        <sequential>
            <delete dir="${test.dir}/@{name}"/>
            <mkdir dir="${test.dir}"/>
            <maven dir="${test.dir}" archetype="@{archetype}"
version="@{version}" name="@{name}"/>

            <!-- copy Person.java to src -->
            <copy todir="${test.dir}/@{name}/src/main/java/com">
                <fileset dir="src/test/java/com" includes="**/*.java"/>
            </copy>

            <!-- add Person to hibernate.cfg.xml -->
            <replace
file="${test.dir}/@{name}/src/main/resources/hibernate.cfg.xml">
                <replacetoken><![CDATA[<mapping
class="org.appfuse.model.Role"/>]]></replacetoken>
                <replacevalue><![CDATA[<mapping
class="org.appfuse.model.Role"/>
        <mapping class="com.company.model.Person"/>]]></replacevalue>
            </replace>

            <!-- run gen install integration-test -->
            <maven dir="${test.dir}/@{name}" command="appfuse:gen
-Dentity=Person"/>
            <maven dir="${test.dir}/@{name}" command="appfuse:install
-Dentity=Person"/>
            <maven dir="${test.dir}/@{name}" command="integration-test"/>

            <!-- test w/o generic core -->
            <maven dir="${test.dir}/@{name}" command="appfuse:gen
-Dentity=Person -Damp.genericCore=false"/>
            <maven dir="${test.dir}/@{name}" command="appfuse:install
-Dentity=Person -Damp.genericCore=false"/>
            <maven dir="${test.dir}/@{name}" command="integration-test"/>
        </sequential>
    </macrodef>

The problem I'm experiencing is if any of the <maven> calls fail, the build
continues and I get no warnings failures.

The full build file is available at:

http://tinyurl.com/2aopar

If anyone has a solution, please let me know. I realize that I could
probably use Maven Embedder 2.1-SNAPSHOT to solve this, but I'd rather not
depend on something that's fluctuating.

Thanks,

Matt
-- 
View this message in context: http://www.nabble.com/Using-Ant-to-test-Maven-Plugins-tf3848312s177.html#a10900020
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org