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>
you get
> 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
The output indicates that the java.library.path hasn't been changed, but some.other.property was set correctly.
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 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
the output will no longer show
[echo] some.other.property=test1
I think you can modify it if you use fork=true in your "java" task. You can supply java.library.path as a nested sysproperty tag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With