Wednesday, June 18, 2008

Copy dependencies to a folder using Ant that runs in Maven

The following plugin copies dependencies of the specific pom to a folder.
Ant is used for this task.


<plugin>
<artifactid>maven-antrun-plugin</artifactid>
<executions>
<execution>
<id>copy-tree</id>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml">
<classpath refid="maven.dependency.classpath">
</typedef>
<pom id="maven.project" file="pom.xml">
<dependencies filesetid="dependency.fileset" usescope="runtime">
<pom refid="maven.project">
</dependencies>
<mkdir dir="target/deps">
<copy todir="target/deps">
<fileset refid="dependency.fileset">
</copy>
</tasks>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupid>org.apache.maven</groupid>
<artifactid>maven-artifact-ant</artifactid>
<version>2.0.4</version>
</dependency>
</dependencies>
</plugin>


via http://www.nabble.com/Using-ant-tasks-inside-antrun-to6994761.html#a6994761

P.S. It's true that it's possible to use the assembly plugin for this specific task. But sometimes things become complex and ANT is essential.

No comments: