Ant support for java 9 addmods option

I am trying to compile my java project with Java 9. I am using the java.xml.bind package, so I need to use the -addmods option to compile. Ant 1.9.7 does not seem to support this new feature. Does the Ant -addmods option support for the Java 9 compiler?

+5
source share
2 answers

There is currently no explicit support for any released version of Ant. But you should be able to use <jvmarg> for this.

 <java ....> <jvmarg value="--add-modules"/> <jvmarg value="module.name.to.add"/> <jvmarg ..../> </java> 

If you are asking about <javac> and not <java> , you can use <compilerarg> instead.

There are several ways in which Java 9 manages to break Ant - and 1.9.8 and 1.10.x will contain many fixes for it (new releases will be released soon after the latest known issues are discovered outside). Right now, there is no explicit support for --add-modules , though, only for modulepath and upgrademodulepath , which were added in Ant 1.9.7.

IMHO - there will be a good request for improvement.

+3
source

Use at least Ant 1.10.1 and do the following in the build.xml file:

 <condition property="java9"> <equals arg1="${ant.java.version}" arg2="9"/> </condition> <java classname="....." fork="true"> <classpath> <pathelement location="...."/> </classpath> <jvmarg value="--add-modules" if:set="java9" /> <jvmarg value="java.xml.bind" if:set="java9" /> ... </java> 
-1
source

All Articles