Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 407
roroco Avatar asked Oct 29 '14 15:10

roroco


People also ask

How do I bypass compileTestJava?

Using Command Line Flags Task :compileTestJava > Task :processTestResources NO-SOURCE > Task :testClasses > Task :test > ... To skip any task from the Gradle build, we can use the -x or –exclude-task option. In this case, we'll use “-x test” to skip tests from the build.

Why is my gradle build failing?

If gradle --version works, but all of your builds fail with the same error, it is possible there is a problem with one of your Gradle build configuration scripts. You can verify the problem is with Gradle scripts by running gradle help which executes configuration scripts, but no Gradle tasks.

How do I run a default task in gradle?

Gradle allows you to define one or more default tasks that are executed if no other tasks are specified. defaultTasks 'clean', 'run' tasks. register('clean') { doLast { println 'Default Cleaning! ' } } tasks.


1 Answers

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"]
        }
    }
}
like image 103
Peter Niederwieser Avatar answered Sep 19 '22 11:09

Peter Niederwieser