I have a third-party Tomcat webapp which is configured with a .properties file processed with ant
before deployment.
One property DB.cache.dir
defines where some temporary files will be created. I would like this property to evaluate literally to ${java.io.tmpdir}
. The purpose being that when running the webapp will use the java.io.tmpdir value of the Tomcat running it rather than the value when it was configured by ant
.
I tried to use \
escape without luck and could not find an answer online.
Please advise.
# How to prevent evaluation for this property?
DB.cache.dir=${java.io.tmpdir}
You need to escape the dollar sign with another dollar sign, e.g.:
DB.cache.dir=$${java.io.tmpdir}
From Properties, Property Expansion, $$ Expansion in the Ant docs:
In its default configuration Ant will expand the text $$ to a single $ and suppress the normal property expansion mechanism for the text immediately following it, i.e., $${key} expands to ${key} and not value even though a property named key was defined and had the value value.