Pointers for a custom Gradle task implementation that has to leverage Java 9's addmods feature

Continuing the discussion from Does Gradle 3 (m1) honor GRADLE_OPTS?:

As mentioned in the linked topic, the XJC plugin leverages AntBuilder. We have been completely unable to get Java 9 addmods working with AntBuilder. Any hints for that?

And if the solution is to re-write a new XJC task (which I am ok undertaking) any pointers on how to make sure that certain JVM args (addmods e.g.) take affect?