How to replace default source folders with gradle?

I am new to Gradle and I have source code different from what Gradle expects.

Gradle expects to find the source in src/main/javayour source code and the test source src/main/resources. How to configure Gradle to a different source code?

+3
source share
1 answer

You need to add some lines to build.gradle:

To replace the default source folders, you will want to use srcDirs instead, which takes an array of paths.

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

Another way to do this:

    sourceSets {
        main {
            java {
                srcDir 'src/java'
            }
            resources {
                srcDir 'src/resources'
            }
        }
    }

The same applies to the test folder.

+9
source

All Articles