我有一个有罐子的目录。我没有他们的名字,我有一个目标,以jar的名称和它的位置,并对它进行操作。
<target name="addAttributes">
<mkdir dir="${folderName}/Temp"/>
<unzip src="${jarNamewtPath}" dest="${folderName}/Temp"/>
<delete file="${jarNamewtPath}"/>
<jar destfile="${jarNamewtPath}">
<manifest>
<attribute name="Application-Name" value="someValue"/>
<attribute name="Trusted-Only" value="true"/>
<attribute name="Codebase" value="*"/>
<attribute name="Permissions" value="all-permissions"/>
</manifest>
<fileset dir="${folderName}/Temp" />
</jar>
<delete dir="${folderName}/Temp"/>
</target>如何获得文件的名称并将其单独传递给这个目标。
<target name="getJars">
<fileset id="getJars" dir="${someDir}/Jars">
<include name="*.jar" />
</fileset>
..... get list of jars
<antcall target="addAttributes">
<param name="folderName" value="${path}"/>
<param name="jarNamewtPath" value="${path}/name.jar"/>
</antcall>
</target>任何帮助/线索都将不胜感激。
发布于 2013-11-21 17:11:57
最好是每个构建只调用一次<target>。对于可以在构建中重复使用的共享功能,请考虑使用。
下面是一个使用第三方Ant-cont肋骨的 task反复调用addAttributes <macrodef>的示例
<project name="ant-for-macrodef" default="getJars">
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<macrodef name="addAttributes">
<attribute name="jar-path"/>
<sequential>
<echo>jar-path: @{jar-path}</echo>
<!-- Make temp.dir locally scoped to this macrodef. -->
<local name="temp.dir"/>
<property name="temp.dir" value="myTempDir"/>
<echo>Perform Jar operations here.</echo>
</sequential>
</macrodef>
<target name="getJars">
<fileset id="getJars" dir="${someDir}/Jars">
<include name="*.jar" />
</fileset>
<for param="jar.file">
<fileset refid="getJars"/>
<sequential>
<addAttributes jar-path="@{jar.file}"/>
</sequential>
</for>
</target>
</project>https://stackoverflow.com/questions/20083165
复制相似问题