如何在蚂蚁中包括途径

发布于 2025-01-31 17:29:15 字数 1360 浏览 4 评论 0原文

我有两个罐子,例如a.jarb.jar。我想使用ANT,将其中一个作为PathElement,具体取决于是否存在属性/存在属性。如果存在属性,我将包括a.jarb.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文