使用ant构建工具从nexus下载jar,在Maven中自动完成

use*_*rcm 4 ant jar download nexus maven

我有一个build.xml(基于ant),它需要来自nexus的一些jar才能复制到现有的lib文件夹中.即,当它构建时,它应该从nexus复制jar,并定义一些版本,然后在lib中复制并进行编译.就像在maven中发生一样,我们定义了工件及其版本.如果更改将自动从maven repo下载.我如何在基于ant的构建中执行此操作?

专家请教.

lan*_*ava 7

我已经将此线程中列出的示例更进了一步,并创建了一个macrodef来清理一些东西以便重复使用.请参阅下文,了解从nexus下载两个工件(一个快照,一个版本).

<project>
<target name="get-all">
    <mkdir dir="lib" />
    <nexus-get 
        groupId="foo.bar" 
        artifactId="some-artifact"
        version="1.0.28"
        repo="releases"
        extension="jar" 
        dest="lib" 
    />

    <nexus-get 
        groupId="foo.bar" 
        artifactId="another-artifact"
        version="1.0.0-SNAPSHOT"
        repo="snapshots"
        extension="jar" 
        dest="lib" 
    />
</target>

<macrodef name="nexus-get">
    <attribute name="groupId"/>
    <attribute name="artifactId"/>
    <attribute name="version"/>
    <attribute name="repo"/>
    <attribute name="extension"/>
    <attribute name="dest"/>

    <sequential>
        <get src="http://my-nexus:9999/nexus/service/local/artifact/maven/redirect?r=@{repo}&amp;g=@{groupId}&amp;a=@{artifactId}&amp;v=@{version}&amp;e=@{extension}" dest="@{dest}/@{artifactId}.@{extension}" usetimestamp="true" />
    </sequential>
</macrodef>
Run Code Online (Sandbox Code Playgroud)