如何获得按住flattenmapper结果蚂蚁? [英] How to get hold on the flattenmapper result in ant?
问题描述
请,看看下面几个目标从我的Ant文件:
Please, find below a few targets from my ant file:
<fileset id="test-dep-jars" dir="o:/java">
<include name="junit-4.10.jar"/>
<include name="easymock-3.1\easymock-3.1.jar"/>
<include name="easymockclassextension-3.1\easymockclassextension-3.1.jar"/>
</fileset>
<target name="copy-test-deps">
<mkdir dir="${deploy.dir}"/>
<copy todir="${deploy.dir}">
<fileset refid="test-dep-jars"/>
<flattenmapper/>
</copy>
</target>
<target name="jar" depends="copy-test-deps">
<jar destfile="${deploy.dir}/test-${ant.project.name}.jar" basedir="${test.classes.dir}"
includes="**/*.class" filesetmanifest="skip">
<manifest>
<attribute name="Class-Path"
value="${ant.project.name}.jar junit-4.10.jar easymock-3.1.jar easymockclassextension-3.1.jar"/>
</manifest>
</jar>
</target>
我的问题是,我必须说明测试的依赖罐子两次 - 定义测试-DEP-jar文件时,文件集一次,并指定生产罐子的类Path清单属性当第二时间
My problem is that I have to state the test dependency jars twice - once when defining the test-dep-jars fileset and the second time when specifying the Class-Path manifest attribute of the produced jar.
如果我只能得到按住flattenmapper结果,那么我就可以使用它在类路径不变。
If I only could get hold on the flattenmapper result, then I would be able to use it in the Class-Path as is.
我怎样才能按住flattenmapper结果?
How can I get hold on the flattenmapper result?
感谢。
推荐答案
我会建议使用的 manifestclasspath 任务,而不是:
I would recommend using the manifestclasspath task instead:
<manifestclasspath property="jar.classpath" jarfile="${jar.file}">
<classpath>
<fileset dir="${deploy.dir}" includes="*.jar"/>
</classpath>
</manifestclasspath>
<jar destfile="${jar.file}" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${jar.main.class}" />
<attribute name="Class-Path" value="${jar.classpath}" />
</manifest>
</jar>
这将产生正确的类路径属性定义,甚至与相对路径的工作(例如,如果你要放在子目录依赖罐)。
It will generate the correct classpath property definition and even works with relative paths (for example if you were to place the dependent jars in sub-directory).
这篇关于如何获得按住flattenmapper结果蚂蚁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!