Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Current »

Passing your Maven classpath to Ant:

In your pom.xml, configure something like this:

In your build.xml, have something like:

The path that maven is using should now be assigned to "runtime-classpath".

This is very useful for calling a custom ant task, when the definition is in your maven classpath. 

Using ant-contrib tasks:

To use ant-contrib tasks with the maven-antrun-plugin you'll need to do a couple of things:

1. Add a taskdef.

2. Add some dependencies for the plugin:

Notice that the transcient dependency on ant:ant is execluded for ant-contrib. This is due to ant-contrib having a dependency on ant-1.5. I was getting the following error before replacing ant with ant-nodeps-1.6.5:

Here's full example of using the antrun plugin to move a war file to a jboss server deploy directory once it is built. You can also define the unpacked property (ie. mvn install -Dunpacked) to have the app moved exploded (or unpacked).

Maven plugin classpath bug.

Using the Maven Antrun Plugin in multiple projects in the Reactor

In Maven 2.x, there is a significant bug that can lead to very perplexing failures with the antrun plugin. There are two conditions that you have to meet to get into this problem.

1) You have to use the plugin in two projects that are loaded into the reactor via <modules/> .
2) You have to require additional plugin dependencies on the plugin.

In Maven 2.x, the dependencies of the first project into the reactor win, and all the others are entirely ignored.

Concretely, if your first project uses the plugin with no special dependencies, and your second one tries to use ant-trax, the second antrun execution will fail, and complain that it can't find the classes in ant-trax.

The only solution to this is to ensure that, in all of the places where you use the plugin, you list the same dependencies.

This problem has been fixed in Maven 3.

  • No labels