How to change the default sources directory name?


#1

Hi, I am using the example from samples\java\withIntegrationTests\ to add a sourceset for integration tests. It configures the source directory as follows:

java.srcDir file('src/integration-test/java')

. The problem is that the default source directory with the name matching the sourset name (“integrationTest”) is still declared and is being created with the following command:

sourceSets.all*.java.srcDirs*.each { it.mkdirs() }

How can I remove the default directory created according to this pattern

[${project.projectDir}/src/${sourceSet.name}/java

(andrew.oberstar) #2

There are two different syntaxes for changing the srcDirs (and this goes with a lot of properties in Gradle).

java.srcDir 'newFolder' //method syntax -- appends to existing
java.srcDirs = ['newFolder', 'otherNewFolder'] //property syntax -- overwrites existing

See the API for more details: http://gradle.org/docs/current/javadoc/org/gradle/api/file/SourceDirectorySet.html