Ant 如何从自定义 Java 系统属性中获取值 [英] How can Ant get the value from custom Java system property
问题描述
在我的 Java 类中,我有
In my java class I have
System.setProperty("test", drinks);
在我的 Ant 构建文件中,我能够执行 jave 类.如何使用名称test"在 Ant 中获得结果 ${drinks} ??
In my Ant build file I am able to execute the jave class. How can I use the name "test" to get the result ${drinks} in Ant ??
推荐答案
如果属性是在命令行中设置的,例如ant -Dtest=drinks
它将在构建系统中以 ${test}
的形式提供,但是如果您通过执行 Java 代码调用此属性,您将需要找到一种方法将值从生成的 Java 进程中取出到一个新变量中,通常使用 System.out.println(...)
和 <exec 的组合...>
任务的 outputproperty
并根据需要进行解析.
If the property is set at the command line e.g. ant -Dtest=drinks
it will be available from the build system as ${test}
, however if you're calling this property by means of executing Java code, you will need to find a way to get the value out from the spawned Java process into a new variable, usually using a combination of System.out.println(...)
and <exec ...>
tasks's outputproperty
and parsing as needed.
这篇关于Ant 如何从自定义 Java 系统属性中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!