Reputation: 1615
I am trying to follow the HelloWorld tutorial for Gradle given by Spring but the Build step is not working - when I run Gradle Build I just see the message, NO-SOURCE for the :compileJava step. I saw on another question that you should add the sourceSets tag into the gradle.build file. I tried this as well and it still doesnt find my Java source files.
I have organised my Java source following the instructions and placed the code inside directory structure,
=>src-main-java-hello ("HelloWorld.java, Greeter.java").
I am using Java8 and Gradle 3.5
Can anyone help please ? - seems a really basic problem I must be having.
Upvotes: 2
Views: 3850
Reputation: 1615
the problem was an embarrassing Gotcha! It had nothing to do with adding the sourceSets configs....my Java files had been saved under Windows using Notepad++ as Text Document files and not Java source files no wonder Gradle was reporting No Source files !! The below screen shot shows the difference.
To avoid this issue when saving your files in Notepad++ you can either wrap the name with quotes or select the Type as a Java Program.
When I changed this and ran gradle.build it all worked fine.
Upvotes: 0
Reputation: 28099
You are defining srcDirs = ['src']
in build.gradle
but then using src/main/java
as your source directory. Since src/main/java
is the (very sensible) default source directory, you can remove your sourceSets { ... }
configuration all together.
Upvotes: 2