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

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

问题描述

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

How to set the path environment variable from ant script

推荐答案

这是用于 任务吗?

您可以在运行 任务时设置环境变量:

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>

可以使用<property environment="env"/>展开路径:

<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"/>

可能将名为 foo 的环境变量设置为 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脚本设置路径环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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