我必须创建一个ant目标,将组件.jar添加到zip文件中。问题是我没有总是定义组件的版本。例如:
<zip destfile="${dist.dir}result-${result-version}.zip">
<fileset dir="${dist.dir}" includes="maincomponent-${maincomponenet-version}*.jar"/>
<fileset dir="${second-componenet-folder}" includes="${second-component-version}.jar" />
</zip>
如果没有定义second-component-version
属性,我如何添加一些条件来创建带有主组件的zip ?
Using Condition and isset
(conditions):
<target name="zip">
<fileset id="main" dir="${dist.dir}" includes="maincomponent-${maincomponenet-version}.jar" />
<fileset id="component" dir="${second-componenet-folder}" includes="${second-component-version}.jar" />
<condition property="jar.file" value="component" else="main">
<isset property="second-component-version"/>
</condition>
<zip destfile="${dist.dir}/result-${result-version}.zip">
<fileset refid="${jar.file}" />
</zip>
</target>