How to set the path environment variable from ant

2019-01-14 00:37发布

How to set the path environment variable from ant script

7条回答
贼婆χ
2楼-- · 2019-01-14 01:14

In ant, properties are immutable, so David's suggestion above:

<property name="env.foo" value="bar!bar"/>

won't work.

But (with the antcontrib-library) variables are mutable, so this works:

<var name="env.foo" value="bar!bar"/>

NOTE: to use the antcontrib-library download it from here: ANT Contrib - Download

This gets the job done, but seems like a dastardly trick.

So to your specific question, try:

<taskdef resource="net/sf/antcontrib/antlib.xml">
    <classpath>
        <pathelement location="${basedir}/lib/ant-contrib-1.0b3.jar" />
    </classpath>
</taskdef>

<var name="env.PATH" value="some:custom:value"/>
查看更多
登录 后发表回答