compileDebugJava - is not incremental. Unable to infer the source directories

送分小仙女□ 提交于 2019-12-10 10:23:26

问题


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


回答1:


Yes, there is an issue for Android Build Plugin, read here:

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

When it is fixed, use this for 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.

From their example for 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




回答2:


I had such issue with react-native addon packages that I have used. I ran react-native link and it seems to have solved the issue.



来源:https://stackoverflow.com/questions/29731754/compiledebugjava-is-not-incremental-unable-to-infer-the-source-directories

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!