Can Gradle handle a build directory structure that does not conform default conventions?
Question
I am working on a java ant+ivy based project that has the following directory structure:
projectRoot/src
projectRoot/classes
projectRoot/conf
projectRoot/webservices
this works perfectly well in ant but I am looking to migrate to gradle.
Is there a way to define a non-maven directory structure in Gradle or should I be looking to mavenize?
Solution
It is very easy with Gradle to adapt to any directory structure. See the Working with source sets section of the Gradle User Guide.
OTHER TIPS
Example with non-standard project directory structure (custom layout):
sourceSets {
main {
java {
srcDir 'sources/main/java'
}
outputDir = file("$workDir/client/program")
// For older version (now deprecated):
//output.classesDir = "$workDir/client/program"
}
test {
java {
srcDir 'sources/test/java'
}
outputDir = file("$workDir/client/tests")
// For older versions (now deprecated):
//output.classesDir = "$workDir/client/tests"
//output.resourcesDir = "$workDir/client/tests"
}
resources {
srcDirs 'sources/test/res'
}
}
Try:
sourceSets {
main {
java {
srcDirs = ['src/java']
}
resources {
srcDirs = ['src/resources']
}
}
}
or
sourceSets {
main.java.srcDirs += 'src/java'
main.resources.srcDirs += 'src/resources'
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow