Adding Long JVM Options to the Ant Launch Command

advertisements

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 java.se.ee 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 java.se.ee
ant -f build.xml --add-modules=java.se.ee
ant -f build.xml -Dadd-modules=java.se.ee
ant -f build.xml -D--add-modules=java.se.ee
ant -f build.xml -propertyfile java9.properties

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

--add-modules java.se.ee

and also with the key and value on separate lines:

--add-modules
java.se.ee


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 java.se.ee"