Skip to content

Instantly share code, notes, and snippets.

@robpurcell
Created June 29, 2012 13:44
Show Gist options
  • Save robpurcell/3018011 to your computer and use it in GitHub Desktop.
Save robpurcell/3018011 to your computer and use it in GitHub Desktop.
Handy Gradle build file snippet for creating a Scala project layout
// Based on http://mrhaki.blogspot.co.uk/2009/11/using-gradle-for-mixed-java-and-groovy.html
// Updated for Gradle 1.0
// Thanks Mr Haki!!
apply plugin: 'scala'
task initProject(description: 'Initialize project directory structure.') << {
// Default package to be created in each src dir.
def defaultPackage = 'com/robbyp/project'
['java', 'scala', 'resources'].each {
// convention.sourceSets contains the directory structure
// for our Scala project. So we use this struture
// and make a directory for each node.
sourceSets*."${it}".srcDirs*.each { dir ->
def newDir = new File(dir, defaultPackage)
logger.info "Creating directory $newDir" // gradle -i shows this message.
newDir.mkdirs() // Create dir.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment