ANT:如何在构建文件中修改 java.library.path [英] ANT: How to modify java.library.path in a buildfile

查看:30
本文介绍了ANT:如何在构建文件中修改 java.library.path的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

java.library.path 属性似乎是只读的.例如,当您在以下构建文件上运行 ant 时

The java.library.path property appears to be read-only. For example when you run ant on the following buildfile

<project name="MyProject" default="showprops" basedir=".">
    <property name="java.library.path" value="test"/>
    <property name="some.other.property" value="test1"/>
    <target name="showprops">
        <echo>java.library.path=${java.library.path}</echo>
        <echo>some.other.property=${some.other.property}</echo>
    </target>
</project>

你得到

> ant -version
Apache Ant version 1.6.5 compiled on June 2 2005

> ant -Djava.library.path=commandlinedefinedpath
Buildfile: build.xml
showprops:
    [echo] java.library.path=commandlinedefinedpath
    [echo] some.other.property=test1
BUILD SUCCESSFUL
Total time: 0 seconds

输出表明 java.library.path 没有改变,但 some.other.property 设置正确.

The output indicates that the java.library.path hasn't been changed, but some.other.property was set correctly.

我想知道如何修改构建文件中的 java.library.path.在 ant 命令行中指定 java.library.path 并不是一个简单的选项,因为当时不知道库路径位置.

I would like to know how to modify the java.library.path within a buildfile. Specifying the java.library.path on the ant command line is not really an easy option, because the library path location is not know at that time.

注意:我希望这样可以工作,以便我可以指定单元测试中使用的本机库的位置.

Note: I would like this to work so that I can specify the location of native libraries used in a unit test.

推荐答案

Ant 属性无法按您预期的方式工作:它们是不可变的,即一旦设置了属性,您就无法更改它的值.如果你跑

Ant properties do not work the way you expect: they are immutable, i.e. you cannot change a property's value after you have set it once. If you run

ant -Dsome.other.property=commandlinedefinedpath

ant -Dsome.other.property=commandlinedefinedpath

输出将不再显示

[echo] some.other.property=test1

[echo] some.other.property=test1

这篇关于ANT:如何在构建文件中修改 java.library.path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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