Is it possible to execute build.xml script with maven? This script checksout all my projects and subprojects and I've just got used to using maven, didn't really use much of an ant before and I know ant can be used with maven so my question is how ?
A:
You can execute ant scripts via the Maven-Ant Plugin, but why do you need Ant to checkout your project? Haven't you organized your sub-projects to be in the same tree?
khmarbaise
2010-05-12 08:53:57
I place ant target between tasks tags and I get this error `Problem: failed to create task or type targetCause: The name is undefined.`
Gandalf StormCrow
2010-05-12 09:06:25
@khmarbaise `Haven't you organized your sub-projects to be in the same tree` - what do you mean ?
Gandalf StormCrow
2010-05-12 09:12:00
+1
A:
I'm really not a big fan of this approach (either use Ant, or Maven, but not a bastard mix) but you can use an external build.xml
with the Maven AntRun Plugin:
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<configuration>
<tasks>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />
<ant antfile="${basedir}/build.xml">
<target name="test"/>
</ant>
</tasks>
</configuration>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
And then run mvn antrun:run
(or put the configuration inside an execution
if you want to bind the AntRun plugin to a lifecycle phase, refer to the Usage page).
Update: If you are using things from ant-contrib, you need to declare it as dependency of the plugin. I've updated the plugin configuration to reflect this. Also note the taskdef
element that I've added (I'm not sure you need the classpathref
attribute though).
Pascal Thivent
2010-05-12 09:58:12
@Pascal Thivent ${basedir} is which location?next to the pom.xml ? or ?
Gandalf StormCrow
2010-05-12 10:13:26
@Gandalf Yes, `${basedir}` represents the directory containing pom.xml
Pascal Thivent
2010-05-12 10:34:29