Ant ignores attempt to override LANG environment variable
We need to check the java assembly with languages set to different values. I can manually (i.e. via export LANG=en_DK.UTF-8
and export LANG=en_DK
) verify that the unit tests run with the ant build script behave differently, but I need to set the environment variable from ant. I tried to install it using these methods (with shell $LANG
set to en_DK.UTF-8
):
- using
-D
on the command line:ant -DLANG=en_DK
- using a file
build.properties
with a lineLANG=en_DK
in it - using the following instructions in your build.xml file (sorry for the formatting, I can't get SO to display it otherwise):
:
<property environment="ANTENV"/>
<property name="ANTENV.LANG" value="en_DK"/>
Using any of the three possibilities, and when run from -debug
, ant reports that:
Override ignored for property "LANG"
What can I do to set the environment variable LANG
from ant?
a source to share
ANT Properties are immutable ,
<property name="ANTENV.LANG" value="en_DK"/>
can be interpreted by ant as trying to override a value LANG
that is already present while storing all environment variables in ANTENV
(with <property environment="ANTENV"/>
).
So, you need to store to store this value in a separate property.
<property name="MY.LANG" value="${env.LANG}" />
a source to share
Assuming your "Java build test" is being invoked <java>
, you can use the fork-flag and pass properties on the newly created process. Here's an example from the Ant documentation :
<java classname="test.Main"
fork="yes" >
<sysproperty key="DEBUG" value="true"/>
<arg value="-h"/>
<jvmarg value="-Xrunhprof:cpu=samples,file=log.txt,depth=3"/>
</java>
a source to share