Created
June 29, 2012 13:44
-
-
Save robpurcell/3018011 to your computer and use it in GitHub Desktop.
Handy Gradle build file snippet for creating a Scala project layout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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