2010-09-16 35 views

回答

3

我偶然发现了这个问题,创建路径因为我读Ivy cachefileset documentation,其中规定:

请喜欢使用检索+ 标准蚂蚁拍的h创作,这使得你的构建更加独立于常青藤 (一旦文物正确检索 ,常春藤不需要任何 更多)。

常春藤cachepath文件同样规定:

如果你想使你的构建更 独立于常春藤,你可以 考虑使用检索任务。一旦 工件被正确检索, 您可以使用标准的Ant路径创建 这使得常春藤没有任何 更多。

因此,似乎更好的答案是修改Mark对使用与蚂蚁路径结合使用检索的回应。沿着以下线的东西:


马克的响应(修改)

<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: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。


注:我只是将这些依赖关系拉入lib目录。这将简化检索任务:

<ivy:retrieve conf="tasks" /> 

还要注意:访问'Path-like Structures' section of this page for more on "standard ant path creation"

5

你在你的蚂蚁lib中唯一需要的罐子常春藤:-)

的ivy.xml文件中声明你的依赖是正常的。利用配置的集体组ANT任务相关的罐子:

<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"/> 
+0

我对这个问题的真实答案还没有完全清楚:你如何确定在 - >的右侧应该发生什么? – Snekse 2011-03-04 17:07:54

+1

“ - >”的右侧是远程模块的配置。在Maven的情况下,这将是范围。默认的Maven作用域是“compile”。同样可以选择其中一个:“主”,“测试”,“运行时”等。在实践中,我使用“默认”或“主”。 – 2011-03-04 20:38:07

2

我会用蚂蚁来安装一切都变成蚂蚁= d

只需使用取决于=“INIT-蚂蚁的contrib时,init-常春藤”

<!-- 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> 

现在,你有蚂蚁的contrib &常春藤,一切应该是一个简单的ivy.xml &常春藤解决掉:

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

我敢肯定,你可以找到任何安装Ant任务,你可能需要的类似的方法。