Search code examples
javamavenantjarbuild

Using Maven in Ant for jar dependencies


Am new to Maven but am comfortable with the Ant, i like the way that maven downloads the jars and its dependencies, so i want to have maven dependency included in my Ant build script. I have seen how to use but here all the jar files are downloaded in .m2 folder, instead i need all the jars downloaded in the lib folder of my project. Can this be done or not,? if it can then can anybody please suggest me how to do it.


Solution

  • I found a way to do this. You have to give filesetid in the artifact tag and use "filesetid" to copy to the given location

    <target name="maven-test">
      <artifact:dependencies filesetid="build-dependency-jars">
        <dependency groupId="group_id" artifactId="artifact_id" version="version" />
      </artifact:dependencies>
            
    <copy todir="./lib/">
        <fileset refid="build-dependency-jars" />
        <mapper type="flatten" />
    </copy>
    
    </target>