Since Gradle 2.1, incremental compilation of Java source is now supported check this
I used below snip of code to enable it
afterEvaluate {
android.applicationVariants.each { variant ->
variant.javaCompile.options.incremental = true
}
}
But I am getting below warning message,
:App:compileDebugJava - is not incremental. Unable to infer the source directories.
Please suggest me what should I do to get rid of it
We use custom sourceset so this is unlikely to be fixed until we can stop using them.
http://code.google.com/p/android/issues/detail?id=82411 and mentioned here
https://discuss.gradle.org/t/faster-incremental-builds/552/10
Android
, add this in allProjects
:allProjects {
tasks.withType(JavaCompile) {
configure(options) {
incremental = true
}
}
}
If you see this, you must build your project first:
compileDebugJava - is not incremental (e.g. outputs have changed, no previous execution, etc.).
If you see this, the wrong sourceSets
are being used according to the isse(see link):
compileDebugJava - is not incremental. Unable to infer the source directories.
Java
projects:apply plugin: 'java'
compileJava {
//enable compilation in a separate daemon process
options.fork = true
//enable incremental compilation
options.incremental = true
}
Source: http://gradle.org/docs/current/dsl/org.gradle.api.tasks.compile.JavaCompile.html