Created
February 24, 2012 05:01
-
-
Save ponkichi7/1897895 to your computer and use it in GitHub Desktop.
Gradle to run Java and Groovy
This file contains 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
fileTree(dir: 'src/main', includes: ['**/*.java','**/*.groovy']).each {File file -> | |
def path = relativePath(file.path) | |
def kind = path.split(/\./).toList().last() | |
def taskName = path - "src/main/${kind}/" - ".${kind}" | |
taskName = taskName.replaceAll('/','.') | |
task "$taskName"(type: JavaExec, dependsOn: classes){ | |
group = "Run" | |
description = "Run the $taskName program($kind)" | |
main = taskName | |
classpath sourceSets.main.output + sourceSets.main.runtimeClasspath | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment