Using the JDTCompiler with Gradle


My question is simple: How can I compile a Java project using JDTCompiler with Gradle 2.4?

I have tried the solution discribe here:

[How to use eclipse JDT compiler with gradle 1.0-milestone-9?][1]

The fisrt one:

compileJava {
        options.compiler = "org.eclipse.jdt.core.JDTCompilerAdapter"
        options.encoding = 'utf-8'
        options.define(compilerArgs: ["-warn:+${warnings.join(',')}"])
        doFirst {
            ClassLoader antClassLoader =
            configurations.ecj.each { File f ->

Give me this error:

A problem occurred evaluating root project ‘SIGRH’.
No such property: compiler for class: org.gradle.api.tasks.compile.CompileOptions

And the last one:

compileJava {
  options.fork = true
  doFirst {
    options.forkOptions.with {
      executable = 'java'
      jvmArgs = [ '-cp', configurations.ecj.asPath, 'org.eclipse.jdt.internal.compiler.batch.Main' ]

Gime me another error:

No such property: module for class: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated
Possible solutions: modules

It is possible to use gradle to compile projects with JDTCompiler? Like Ant does?

<!--Ant scritp -->
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter" />

I wil appreciate if someone can help me.