[英]How to add Ivy to Ant dynamically
Typically, to make Ivy tasks available to an Ant build, you need to: 通常,要使Ivy任务可用于Ant构建,您需要:
ivy.jar
to ${ANT_HOME}/lib
. ivy.jar
添加到${ANT_HOME}/lib
。 xmlns:ivy="antlib:org.apache.ivy.ant"
declaration to your build.xml's <project>
element. xmlns:ivy="antlib:org.apache.ivy.ant"
声明添加到build.xml的<project>
元素中。 <taskdef>
declaration inside build.xml that reference's the ivy.jar
's antlib.xml
file where all other tasks are defined. <taskdef>
声明,引用ivy.jar
的antlib.xml
文件,其中定义了所有其他任务。 I'd like to accomplish all of the above except the first step (adding ivy.jar
to ${ANT_HOME}/lib
). 除了第一步(将
ivy.jar
添加到${ANT_HOME}/lib
) 之外 ,我想完成上述所有操作。 I'd like to have ivy.jar
living somewhere inside my project, say, at lib/buildtime/ivy.jar
, and somehow reference lib/buildtime/ivy.jar
as where Ivy is located. 我想让
ivy.jar
住在我的项目中的某个地方,例如,在lib/buildtime/ivy.jar
,并以某种方式引用lib/buildtime/ivy.jar
作为Ivy所在的位置。
Is this possible? 这可能吗? If so, how?
如果是这样,怎么样? If not, why?
如果没有,为什么? Thanks in advance!
提前致谢!
The taskdef (step 3) is not required if the ivy jar is located in a standard ANT library directory. 如果常春藤罐位于标准ANT库目录中,则不需要taskdef(步骤3)。
I would recommend including a special "bootstrap" target that will install the ivy jar. 我建议包括一个特殊的“bootstrap”目标,它将安装常春藤罐。 Once this is done all other dependencies (including 3rd party ANT tasks) can be downloaded by ivy as a build dependency.
完成此操作后,ivy可以将所有其他依赖项(包括第三方ANT任务)作为构建依赖项下载。
Here is my default build file that demonstrates the concept: 这是我的默认构建文件,演示了这个概念:
<project name="demo" default="resolve" xmlns:ivy="antlib:org.apache.ivy.ant">
<target name="bootstrap" description="Install ivy">
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar"/>
</target>
<target name="resolve" description="Use ivy to resolve classpaths">
<ivy:resolve/>
<ivy:report todir='build/ivy-reports' graph='false' xml='false'/>
<ivy:cachepath pathid="compile.path" conf="compile"/>
<ivy:cachepath pathid="test.path" conf="test"/>
</target>
<target name="clean" description="Cleanup build files">
<delete dir="build"/>
</target>
<target name="clean-all" depends="clean" description="Additionally purge ivy cache">
<ivy:cleancache/>
</target>
</project>
Notes: 笔记:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.