Is there a way I can use Maven repositories to add dependencies to Ant?

后端 未结 4 420
滥情空心
滥情空心 2020-12-19 03:38

I was wondering if anybody has seen a technique for adding Maven dependencies to Ant. I thought that Ivy was meant to do this but then I realized that it is only an Ant-sty

相关标签:
4条回答
  • 2020-12-19 04:00

    What i use is the dependency:copy-dependencies maven goal. This will copy all dependencies on target/dependencies so i only need to include all jars on that folder on one ant classpath.

    0 讨论(0)
  • 2020-12-19 04:03

    There are a set of ant tasks for Mercury that allow you to perform dependency management tasks, specify configuration (e.g. server credentials), modify/alter the ant path and write to the repository. See this blog for details.

    There are also Maven tasks for ant, though they are not as fully featured. Maven is moving towards Mercury (particularly for Maven3) so it makes sense to use the Mercury tasks.

    The following configuration reads the dependencies from the specified pom and populates the specified variable with the resultant path:

    <path id="my.compile.path">
      <deps>
        <dependency name="groupId:artifactId:1.0::pom" 
            pom="${basedir}/artifactId-1.0.pom"/>
      </deps>
    </path>
    
    0 讨论(0)
  • 2020-12-19 04:08

    Agree with Jherico's answer - the Maven Ant Tasks. Refer this: Why you should use the Maven Ant Tasks instead of Maven or Ivy

    It has detailed examples, which should get you going.

    0 讨论(0)
  • 2020-12-19 04:20

    The Maven has a set of Maven ant tasks that can downloaded and placed in your Ant lib directory. After that, you can declare a classpath in Ant that is defined by the dependencies in your POM. This is an example of what you can declare in your build.xml.

    <artifact:dependencies filesetId="deps.fileset" type="jar">
      <pom file="mypom.xml"/>
    </artifact:dependencies>
    

    More details can be found here and here.

    0 讨论(0)
提交回复
热议问题