使用常春藤下载/安装ant contrib、bsf、beanshell、commons日志

使用常春藤下载/安装ant contrib、bsf、beanshell、commons日志,ant,ivy,beanshell,ant-contrib,Ant,Ivy,Beanshell,Ant Contrib,我正在使用Ant和Ivy构建一个项目。build.xml文件依赖于、和 Ant在多个位置搜索库,包括${user.home}/.Ant/lib 在build.xml文件中是否有任何方法可以让这些库自动下载并安装在${user.home}/.ant/lib目录中(如果它们还不存在),或者使用Ivy本身 谢谢,拉尔夫,你的蚂蚁库中唯一需要的罐子就是常春藤:-) 在ivy.xml文件中将依赖项声明为正常。使用配置对与ANT任务关联的JAR进行集体分组: <configurations>

我正在使用Ant和Ivy构建一个项目。
build.xml
文件依赖于、和

Ant在多个位置搜索库,包括
${user.home}/.Ant/lib

build.xml
文件中是否有任何方法可以让这些库自动下载并安装在
${user.home}/.ant/lib
目录中(如果它们还不存在),或者使用Ivy本身


谢谢,拉尔夫,你的蚂蚁库中唯一需要的罐子就是常春藤:-)

ivy.xml文件中将依赖项声明为正常。使用配置对与ANT任务关联的JAR进行集体分组:

<configurations>
    <conf name="tasks" description="Ant tasks"/>
</configurations>

<dependencies>
    <dependency org="ant-contrib" name="cpptasks" rev="1.0b5" conf="tasks->default"/>
    <dependency org="junit" name="junit" rev="3.8" conf="tasks->default"/>
    ..

..
build.xml文件中,可以从该配置创建路径

<ivy:resolve/>
<ivy:cachepath pathid="tasks.path" conf="tasks"/>

<taskdef name="task1" classname="??" classpathref="tasks.path"/>
<taskdef name="task2" classname="??" classpathref="tasks.path"/>

我在阅读报告时遇到了这个问题,其中说明:

请选择使用“检索”+ 标准ant路径创建,使 你的身材更独立于常春藤 (一旦工件被正确处理 检索时,不需要任何常春藤 更多)

Ivy cachepath文档类似地指出:

如果你想让你的构建更 独立于常春藤,你可以 考虑使用检索任务。一旦 这些文物被正确地取回, 您可以使用标准的Ant路径创建 这就不需要常春藤了 更多

因此,更好的答案似乎是修改Mark对使用retrieve和ant路径的响应。大致如下:


马克的回答(修改)


..
build.xml文件中,您可以从该配置创建路径

<ivy:retrieve conf="tasks"
     pattern="${dir.where.you.want.taskdef.jars}/[artifact]-[revision].[ext] />

<path id="tasks.path">
  <fileset dir="${dir.where.you.want.taskdef.jars}">
    <include name="**/*.jar"/>
  </fileset>
</path>

<taskdef name="task1" classname="??" classpathref="tasks.path"/>
<taskdef name="task2" classname="??" classpathref="tasks.path"/>

我会使用ant将所有内容安装到ant=d中

只需使用depends=“init ant contrib,init ivy”


现在您有了ant contrib和ivy,其他所有内容都应该是一个简单的ivy.xml和ivy解析:

<target name="resolve" depends="init-ivy">
    <ivy:retrieve />
  </target>


我相信您可以找到类似的方法来安装您可能需要的任何ant任务。

我还不完全清楚这个问题的真正答案:如何确定->右侧应该安装什么?“->”右侧是远程模块的配置。对于Maven来说,这就是范围。默认的Maven范围是“compile”。可以选择其他选项中的一个:“主控”、“测试”、“运行时”等。在实践中,我使用“默认”或“主控”。
<ivy:retrieve conf="tasks" />
<!-- ANT-CONTRIB Auto Installer -->
<available property="ant-contrib-exists"
           file="${ant.library.dir}/ant-contrib-1.0b3.jar" />
<target name="download-ant-contrib" unless="ant-contrib-exists">
  <mkdir dir="${ant.library.dir}" />
  <get src="http://downloads.sourceforge.net/project/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3-bin.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fant-contrib%2Ffiles%2Fant-contrib%2F1.0b3%2F&amp;use_mirror=cdnetworks-us-1"
       dest="${ant.library.dir}/ant-contrib-1.0b3-bin.zip"
       username="true" />
  <unzip src="${ant.library.dir}/ant-contrib-1.0b3-bin.zip"
         dest="${ant.library.dir}"
         overwrite="no" />
  <move todir="${ant.library.dir}">
    <fileset file="${ant.library.dir}/ant-contrib/*.jar" />
    <fileset file="${ant.library.dir}/ant-contrib/lib/*.jar" />
  </move>
  <delete file="${ant.library.dir}/ant-contrib-1.0b3-bin.zip" />
  <delete dir="${ant.library.dir}/ant-contrib" />
</target>
<target name="init-ant-contrib" depends="download-ant-contrib">
  <taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
      <pathelement location="${ant.library.dir}/ant-contrib-1.0b3.jar" />
    </classpath>
  </taskdef>
</target>

<!-- IVY Auto Installer -->
<property name="ivy.install.version" value="2.1.0-rc2" />
<condition property="ivy.home" value="${env.IVY_HOME}">
  <isset property="env.IVY_HOME" />
</condition>
<property name="ivy.home" value="${user.home}/.ant" />
<property name="ivy.jar.dir" value="${ivy.home}/lib" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<available file="${ivy.jar.file}" property="ivy-exists" />
<target name="download-ivy" unless="ivy-exists">
  <mkdir dir="${ivy.jar.dir}" />
  <!-- download Ivy from web site so that it can be used even without any special installation -->
  <get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
       dest="${ivy.jar.file}"
       usetimestamp="true" />
</target>
<target name="init-ivy" depends="download-ivy">
  <!-- try to load ivy here from ivy home, in case the user has not already dropped
              it into ant's lib dir (note that the latter copy will always take precedence).
              We will not fail as long as local lib dir exists (it may be empty) and
              ivy is in at least one of ant's lib dir or the local lib dir. -->
  <path id="ivy.lib.path">
    <fileset dir="${ivy.jar.dir}" includes="*.jar" />
  </path>
  <taskdef resource="org/apache/ivy/ant/antlib.xml"
           uri="antlib:org.apache.ivy.ant"
           classpathref="ivy.lib.path" />
</target>
<target name="resolve" depends="init-ivy">
    <ivy:retrieve />
  </target>