Antrun Plugin

Passing your Maven classpath to Ant:

In your pom.xml, configure something like this:

   <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>build-config-files</id>
            <phase>compile</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <property name="runtime-classpath" refid="maven.runtime.classpath"/>
                <ant target="build" inheritRefs="true"/>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

In your build.xml, have something like:

     <path id="project.class.path">
        <path path="${runtime-classpath}"/>
    </path>

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. 

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Oct 14, 2008

    Andy Schlaikjer says:

    Newer versions of maven-antrun-plugin seem to pass "maven.runtime.classpath" and...

    Newer versions of maven-antrun-plugin seem to pass "maven.runtime.classpath" and friends to Ant as valid Ant paths as long as inheritRefs="true". No need to assign to an intermediate property.