compileJava task NO_SOURCE with right folder structure

Hello everyone I’m pretty new to gradle and it seems I stuck with the configuration step in gradle. I’m studying an open source project and cloned it locally. Then I added gradle file into the root project.
I tried to run “gradle build” task and it always gives me the message “compileJava NO_SOURCE”. So I double checked the project folder structure and it looks fine. (I’m sorry I can only post one image as a new user)
Any clues to this? Appreciate for any suggestions.
In build.gradle file, I only added java plugin and two dependencies.

It seems I have to use src/main/java instead of crawler4j/src/main/java. Hope it helps if other people met the same issues.

By placing build.gradle in the root folder, you have only a single project build. As you noted in your edit, the root directory does not have a src/main/java folder. It’s nested under, crawler4j, which is actually another module in the Maven build, and can be treated as a sub-project in Gradle.

If you look at the pom.xml in the root directory, you can see multiple modules are defined:

<modules>
    <module>crawler4j</module>
    <module>crawler4j-examples/crawler4j-examples-base</module>
    <module>crawler4j-examples/crawler4j-examples-postgres</module>
</modules>

This would be a multi-project build in Gradle. You can create a settings.gradle to have a multi-project build that replicates the Maven module setup, although you can omit the crawler4j-examples until you’re ready to work with them:

settings.gradle

include 'crawler4j'
include 'crawler4j-examples:crawler4j-examples-base'
include 'crawler4j-examples:crawler4j-examples-postgres'

You would then apply the java plugin and add dependencies for the crawler4j project rather than the root project.

Thank you very much for your helpful advice. I think I will study multi build more later so for now I added these code into build.gradle and it works:(so only one subProject is built I think)

sourceSets {
    main {
        java {
            srcDirs = ['crawler4j/src/main/java']
        }
        resources {
            srcDirs = ['crawler4j/src/main/resources']
        }
    }
}

But the wield thing is there are no dependencies get injected inside runtime classpath so I can’t run the class containing main method directly.(Ex: in eclipse) I use “Compile” for all my dependencies declared inside build.gradle. So the workaround I’m using right now is to build a fatJar and run it. But it is kind of annoying is there a way to run the class directly inside IDE?