Configuring location of Java source files


(George Smith) #1

Our team has a different standard for where Java source and test files reside. How can we tell gradle where these files are?


(René Groeschke) #2

Hey George, Assuming your team is using the java plugin, you can change the default locations for your source files

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

Have a look at the SourceSet chapter in the gradle userguide (http://gradle.org/docs/current/userguide/java_plugin.html#sec:source_sets ) or at the Gradle DSL reference (http://gradle.org/docs/current/dsl/org.gradle.api.tasks.SourceSet.html)

regards, René