Is there a task to create src/main/java/ and similar directories?

hi, i am used to the eclipse style directory structure (src/, tst/, etc.).

is there a built in task for creating src/main/java, src/test/java, etc.?

or should i roll my own.


maybe i can iterate over java.srcDirs and resources.srcDirs for the java part?



At the moment, there’s no task to create those dirs for you. You can iterate the srcDirs and create them from the build script (e.g. in some custom task). We plan to improve the bootstrap plugin to have tasks to create a quickstart java app, etc.

Hope that helps!

looking at the sourceSetJavaProperties example from the new gradle book (please see below), i can iterate over some of the source sets if i have the java plugin

sourceSets.each { set->println “set $set” } { File file -> println “java dir $file” } { File file -> println “java dir $file” }

the above works fine.

but trying to get the resources dirs does not.

println sourceSets.main.resources.dump() // is confusing

but println “resources.srcDirs = ${resources.srcDirs}” works in the sample from the book.


task sourceSetJavaProperties << {

sourceSets {

main {

println “java.srcDirs = ${java.srcDirs}”

println “resources.srcDirs = ${resources.srcDirs}”

println “java.files = ${}”

println “allJava.files = ${}”

println “resources.files = ${}”

println “allSource.files = ${}”

println “output.classesDir = ${output.classesDir}”

println “output.resourcesDir = ${output.resourcesDir}”

println “output.files = ${output.files}”


} }

found this link in the gradle in action book.

Eric Berry’s gradle-templates is the most effective way to create archetypes.

Just remember to run it without the daemon enabled, since several of the tasks prompt the user, and it utilizes System.console() which currently is not proxied by the daemon like raw stdin, stdout, and stderr are.


… Just remember to run it without the daemon enabled …

thanks for the warning

My 2 cents is… its a feature flaw that the Java, Groovy, WebApps etc plugins do not have a task to flesh out the src / test directories etc that they expect anyway.

As far as I know the plugins expect certain directory layouts e.g. main/groovy main/resources etc

Why leave it up to the developer to figure this out? Especially frustrating for a noob. Makes the learning curve harder.

Gradle 1.7 and 1.8 can already create the necessary directories for a Java library project, and 1.9 will support several other project types as well. For details see the release notes or user guide (build setup plugin).

just need to add Groovy and web app to the build setup plugin (with the resources dir too)