But I got compiler errors, it seems ant always using ‘javac’. After digging into gradle’s source, I found ‘AntJavaCompiler.execute’ uses a new instance of AntBuilder for every compilation. So I have no chance to specify an alternative compiler, without touching the deprecated ‘options.compiler’ property.
So, is there a way to use an alternative compiler, through an Ant CompilerAdapter (such as JDTCompilerAdapter)?
If you need to use an Ant CompilerAdapter, ‘options.compiler’ together with ‘options.useAnt = true’ is the only way. Aren’t there any other ways to use the Eclipse JDT compiler, for example as a standalone Java application?
Instead of ‘options.define compilerArgs: […]’, ‘options.compilerArgs = …’ should be used.
We could think about making it easier to execute Java compilers from a main method, or add special support for the Eclipse compiler. Ant’s ‘options.compiler’ is unlikely to come back because Gradle’s ‘Compile’ task is slowly but surely moving away from Ant. Of course, you’ll always be able to use an Ant task (like javac) directly.