Is there a way I can use Maven repositories to add

2019-01-26 09:03发布

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-style tool for dependency management.

It seems to me that if somebody extended Ant to be able to reference Maven dependencies (perhaps only for open source libraries) Ant could piggyback at least one great feature of Maven without having to re-invent the wheel.

Any thoughts?

标签: maven-2 ant
4条回答
我命由我不由天
2楼-- · 2019-01-26 09:38

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.

查看更多
做个烂人
3楼-- · 2019-01-26 09:43

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.

查看更多
老娘就宠你
4楼-- · 2019-01-26 09:56

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.

查看更多
家丑人穷心不美
5楼-- · 2019-01-26 09:58

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>
查看更多
登录 后发表回答