<propertyset> and <syspropertyset> http://ant.apache.org/manual/Types/propertyset.html应该是你正在寻找的
也可以看看例如。
您可以在 java ant 任务中一一设置它们:
<sysproperty key="test.classes.dir"
value="${build.classes.dir}"/>
乏味......或者你可以将它们作为 Ant 属性块传递下来:
<syspropertyset>
<propertyref prefix="test."/>
</syspropertyset>
您可以引用外部系统属性:
<propertyset id="proxy.settings">
<propertyref prefix="http."/>
<propertyref prefix="https."/>
<propertyref prefix="socks."/>
</propertyset>
然后在您的 java ant 任务中使用它们:propertyset
可按需使用;当传递到新进程时,所有当前匹配给定前缀的 ant 属性都会被传递:
<java>
<!--copy all proxy settings from the running JVM-->
<syspropertyset refid="proxy.settings"/>
...
</java>
我完全错过了你试图通过的事实java.library.path
财产!
正如中提到的这个线程 http://lists.apple.com/archives/java-dev/2005/May/msg00519.html:
如果您尝试在 java 任务之外设置其值,Ant 会忽略它。因此,我将除该属性之外的所有属性都放入我的 syspropertyset 中,并且它按预期工作。
meaning:
<property name="java.library.path" location="${dist}"/>
<propertyset id="java.props">
<propertyref name="java.library.path"/>
</propertyset>
<target name="debug">
<java>
<syspropertyset refid="java.props"/>
</java>
</target>
不会起作用,但以下应该:
<target name="debug">
<java>
<sysproperty key="java.library.path" path="${dist}"/>
</java>
</target>
(尽管你可以尝试使用“fork
"如果不起作用,属性设置为true)
(注:你但无法修改其值 https://stackoverflow.com/questions/422848/ant-how-to-modify-java-library-path-in-a-buildfile)