开发者

environment variable in ant that persists into runtime

开发者 https://www.devze.com 2023-02-08 23:09 出处:网络
Is it possible to set an environment variable in ant that persists into runtime? I\'ve tried in t开发者_Python百科he build.xml.

Is it possible to set an environment variable in ant that persists into runtime? I've tried in t开发者_Python百科he build.xml. Any suggestions?


If you are trying to execute an external command and want to modify the environment, use the env tag. The same tag exists for the java and junit tags.

<exec executable="cmd">
    <env key="variable" value="info" />
</exec>

See the ant env specification for more information.

For any other tags, you will have to pass in the variable as an attribute.


Environment variables belong to processes, not executables. Compilation happens in a different process than running. So unless ant is being used to actually run the program, ant cannot affect the run time environment.

That said, you can certainly set things up so that, for instance, certain variables get written by ant to a configuration file, and then at run-time the Java process will read that configuration file. So what you want to do can be done. But not through environment variables.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号