如何在蚂蚁中包括途径
我有两个罐子,例如a.jar
和b.jar
。我想使用ANT,将其中一个作为PathElement
,具体取决于是否存在属性/存在属性。如果存在属性,我将包括a.jar
和b.jar
否则。 但是,我的路径
在target
之外声明。最好的方法是什么?
这是我现有脚本的snipplet。请查看可以进行哪些更改。谢谢。
...
<property name="utils.jar.name" value="a.jar" />
...
<condition property="utils.jar.name.set" else="false">
<isset property="utils.jar.name"/>
</condition>
...
<path id="master-classpath">
<pathelement path="${build.dir}" />
<!--
if utils.jar.name.set then
<pathelement path="${utils.project.dist.dir}/lib/${utils.jar.name}" />
else
<pathelement path="${utils.project.dist.dir}/lib/b.jar" />
-->
<path refid="extlib-to-deploy" />
...
</path>
...
<target name="build" description="...">
<mkdir dir="${build.dir}" />
<javac destdir="${build.dir}" source="1.8" target="1.8" failonerror="true" debug="${compile.debug}">
<src path="${src.dir}" />
<classpath refid="master-classpath" />
</javac>
<copy todir="${build.dir}">
<fileset dir="${res.dir}" />
</copy>
</target>
I have two jars, say a.jar
and b.jar
. I want to, using Ant, include either one of them as pathelement
depending on whether a property is set/exists. If the property exists, I will include a.jar
and b.jar
otherwise.
However, I have my path
declared outside of target
. What would be the best way to do this?
Here is snipplet of my existing script. Please see what changes can be made. Thank you.
...
<property name="utils.jar.name" value="a.jar" />
...
<condition property="utils.jar.name.set" else="false">
<isset property="utils.jar.name"/>
</condition>
...
<path id="master-classpath">
<pathelement path="${build.dir}" />
<!--
if utils.jar.name.set then
<pathelement path="${utils.project.dist.dir}/lib/${utils.jar.name}" />
else
<pathelement path="${utils.project.dist.dir}/lib/b.jar" />
-->
<path refid="extlib-to-deploy" />
...
</path>
...
<target name="build" description="...">
<mkdir dir="${build.dir}" />
<javac destdir="${build.dir}" source="1.8" target="1.8" failonerror="true" debug="${compile.debug}">
<src path="${src.dir}" />
<classpath refid="master-classpath" />
</javac>
<copy todir="${build.dir}">
<fileset dir="${res.dir}" />
</copy>
</target>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论