I do it all the time. It's allowed us to start migrating our Ant build
project-by-project to Maven without retraining our dev monkeys during
the transition ;-). Projects that have been converted to Maven now have
bare-bones build.xml files for per-project customization, but the
majority of functionality is imported from a common template build file.
The heart of the template is the following target:

        <target name="_runMaven">
                <exec executable="mvn.bat" os="Windows NT, Windows 2000,
Windows XP, Windows 2003" failonerror="true">
                        <env key="MAVEN_TERMINATE_CMD" value="on" />
                        <arg line="${mavenTarget}"/>
                </exec>
                <exec executable="mvn" os="Linux, Solaris, SunOS, Mac OS
X" failonerror="true">
                        <arg line="${mavenTarget}"/>
                </exec>
        </target>

The MAVEN_TERMINATE_CMD is (or was?) vital for catching errors on
Windows and obviously this is customized for our supported OSes. This
target is then called from a number of pass-through targets that convert
existing expected Ant targets to Maven calls, such as:

        <target name="test">
                <antcall target="_runMaven">
                        <param name="mavenTarget" value="test"/>
                </antcall>
        </target>

This relies on the supporting build.xml being in the same directory as
you want to run Maven, but you could easily add another parameter to
pass to _runMaven for a directory to run the <exec> in. I believe there
are no plans for an Ant task, as you can read about here:

http://jira.codehaus.org/browse/MNG-2127

And for credit's sake, that's probably where I got the gist of what I've
written above. 

Chris

> -----Original Message-----
> From: Douglas Ferguson [mailto:[EMAIL PROTECTED] 
> Sent: Friday, 01 September, 2006 15:54
> To: users
> Subject: Scripts for building multiple projects
> 
> I just wrote a script to build a couple of modules in a 
> specific order, for dev purposes.
> 
>  
> 
> Once I did this, I thought that it might be handy to make it 
> an ant script.
> 
> Anybody call mvn from ant before? Just wondering if there are 
> any tasks for this already?
> 
>  
> 
> Here's my shell script...
> 
>  
> 
> pushd framework
> 
> mvn clean install
> 
> popd
> 
> pushd ev
> 
> mvn clean install
> 
> popd
> 
> pushd custom-builds/ev-builds/di
> 
> mvn clean compile war:war cargo:undeploy cargo:deploy 
> -Premote.localhost
> 
> popd
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to