Handy Gradle startup script


Dierk published a gist on GitHub with a handy Gradle build script to help you bootstrap a Gradle-built project from scratch, without having to create the directory layout manually, or install the Gradle wrapper. 

This is pretty neat and should be integrated in Gradle to ease the creation of projects!

I've updated the gist with a more recent version of Groovy and Gradle.

And so that I never forget about this handy Gradle build script, I'm blogging about it and reproducing it here, to save me precious minutes finding it again the next time I need it! So without further ado, here's the script in question:
apply plugin : 'groovy'
apply plugin : 'idea'
repositories { mavenCentral() }
dependencies {
    groovy 'org.codehaus.groovy:groovy-all:1.8.4'
}
task makeDirs(description : 'make all dirs for project setup') << {
    def sources = [sourceSets.main, sourceSets.test]
    sources*.allSource*.srcDirs.flatten().each { File srcDir ->
        println "making $srcDir"
        srcDir.mkdirs()
    } 
}
task wrap(type : Wrapper, description : "create a gradlew") {
    gradleVersion = '1.0-milestone-6'
}

 

 
© 2012 Guillaume Laforge | The views and opinions expressed here are mine and don't reflect the ones from my employer.