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
the output will no longer show