gradle: Skipping task ':compileJava' as it has no source files

ぐ巨炮叔叔 提交于 2020-02-23 09:22:10

问题


i try gradle -d compileJava in my try project, and gradle raise "Skipping task ':compileJava' as it has no source files.". the worse thing is that i can't see anything created in build/. i create this project only with running gradle init and creating a "src/Ex.java".

my question is:

How to load default "compileJava" or define my "compileJava" to fix this warning.


回答1:


By default, Java source files need to go into src/main/java (or src/test/java for test sources). Either adapt your directory structure accordingly, or reconfigure the source directory as follows:

sourceSets {
    main {
        java {
            srcDirs = ["src"]
        }
    }
}



回答2:


You can also change gradle version to 4.8 in

gradle-wrapper.properties 
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip

then do:

./gradlew build


来源:https://stackoverflow.com/questions/26634000/gradle-skipping-task-compilejava-as-it-has-no-source-files

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