How to compile with Eclipse compiler in Gradle 2.2.1?


I am trying to integrate the gradle build with Eclipse, so Eclipse compiles the source and get hot deployment of the compiled class files without having to restart Tomcat every time.

I’ve managed to launch gradle from inside Eclipse as a external Program, but it uses its own JVM and compiler so Eclipse is not aware of it.

I searched this forum and found this useful link:

but it looks like there is no options.compiler available:

* What went wrong:
A problem occurred evaluating root project 'kv-platform'.
> No such property: compiler for class: org.gradle.api.tasks.compile.CompileOptions
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Apart from that I read in the previous forum post that the team in Gradle would work in a proper way to do this. Is there something I am missing?

Thanks so much!!

Hello, I figured out a way to do this:

// We configure here this task from the Java Plugin to use (or not) the Eclipse Compiler instead of the built-in one to enable hot deployment
// If the Eclipse Compiler is used, the compiler process is forked using the compiler bundled with Eclipse
compileJava {
    dependsOn createDirs
    doFirst {
      setDefaultProperty("useEclipseCompiler", true)
      def useEclipseCompiler = Boolean.parseBoolean("$project.ext.useEclipseCompiler")
      if (useEclipseCompiler) {
      println "Compiling main Java source using Eclipse compiler..."
      options.fork = true
      options.compilerArgs = ['-target','1.7','-source','1.7']
        options.forkOptions.with {
        executable = 'java'
        jvmArgs = ['-classpath', files("$baseDir/eclipse/org.eclipse.jdt.core_3.10.0.v20140902-0626_4.4.jar","$baseDir/eclipse/jdtCompilerAdapter_4.4.jar").getAsPath(), 'org.eclipse.jdt.internal.compiler.batch.Main']
    } else {
      println "Compiling main Java source..."
    sourceCompatibility = 1.7
  classpath = sourceSets.main.compileClasspath
  destinationDir = classesDir
  options.encoding = 'utf-8'

Although this is working fine, I still think there should be a proper way to use the Eclipse compiler without having to fork a different process with the compiler and having the jar files extracted from the Eclipse distribution.

Hope this helps and thanks in advance