<tasks>
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${settings.localRepository}/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${settings.localRepository}/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar" />
<for param="file">
<path>
<dirset dir="src/main/bootstrap" includes="/*" />
</path>
<sequential>
<basename property="dir" file="@{file}" />
<zip destfile="${project.build.outputDirectory}/alfresco/extension/agilent/${dir}.acp" basedir="@{file}" />
</sequential>
</for>
</tasks>
但属性目录是不可改变的!并且所有存档都有名称“1.acp”。如何使这个属性变得可变或以另一种方式做到这一点?
答案 0 :(得分:6)
您可以使用1.8 Ant的Local task
在你的情况下:
<sequential>
<local name="dir"/>
<basename property="dir" file="@{file}"/>
<zip
destfile="${project.build.outputDirectory}/alfresco/extension/agilent/${dir}.acp"
basedir="${dir}"
/>
</sequential>
答案 1 :(得分:4)
您可以使用ant contrib的var task
属性unset
允许您重置值(例如,从上面的链接开始):
<property name="x" value="6"/>
<echo>${x}</echo> <!-- will print 6 -->
<var name="x" unset="true"/>
<property name="x" value="12"/>
<echo>${x}</echo> <!-- will print 12 -->
所以你必须修理它:
<sequential>
<var name="dir" unset="true"/>
<basename property="dir" file="@{file}" />
<zip destfile="${project.build.outputDirectory}/alfresco/extension/agilent/${dir}.acp" basedir="@{file}" />
</sequential>