如何设置从Ant脚本中的PATH环境变量 [英] How to set the path environment variable from ant script

查看:505
本文介绍了如何设置从Ant脚本中的PATH环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从ant脚本设置PATH环境变量

How to set the path environment variable from ant script

推荐答案

这是一个<&EXEC GT; 任务

您可以设置环境变量,当您运行<&EXEC GT; 任务:

You can set environment variables when you run an <exec> task:

<exec executable="${my.command}">
    <env key="foo" value="bar"/>
    <arg line="some value"/>
</exec>

您可以使用&LT;物业环境=ENV/&GT; 来拓展的路径:

You can use <property environment="env"/> to expand the path:

<property environment="env"/>
<exec executable="${my.command}">
   <env key="PATH" value="${env.PATH}:${my.directory}"/>
</exec>

如果这是一个需要环境变量一些自定义任务,但不会允许你设置环境变量的任务,如果没有设置一个,你可以尝试设置它:

If this is for some custom task that requires an environment variable, but doesn't allow you to set the environment variable in the task if one isn't set, you can try setting it in:

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

可能设置名为条的值的环境变量!吧!。我还记得一些关于这一点,但无法得到它的工作。

This might set an environment variable called foo to the value of bar!bar!. I remember something about this, but wasn't able to get it to work.

您可以做的另一件事是有一个Ant脚本执行另一个并具有第一ant脚本设置环境值。我这样做的时候,我不得不设置 ANT_OPT

The other thing you can do is have one ant script execute another and have the first ant script set the environment value. I did this when I had to set ANT_OPT.

这篇关于如何设置从Ant脚本中的PATH环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆