Adding Long JVM Options to the Ant Launch Command


Similar to this question, I am looking for a way to supply long options (i.e. --long-option myVal) to the JVM used by ant. However, my question is different because I want to specify these JVM options to the ant process itself, not some sub-process that ant creates (e.g. <java>).

Specifically, I need to specify --add-modules so that the ant tasks run by my build scripting have access to the JAXB classes.

What I have tried so far:

ant -f build.xml --add-modules
ant -f build.xml
ant -f build.xml
ant -f build.xml
ant -f build.xml -propertyfile

For the -propertyfile option I have tried having the contents of as:


and also with the key and value on separate lines:


Finally found the answer in the ant-users mailing list.

You can specify ANT_OPTS as an environment variable and it will apply those options to the JVM (commonly used for increasing max heap size).

In my case the solution was doing:

export ANT_OPTS="--add-modules"