Skip to content

Instantly share code, notes, and snippets.

@ponkichi7
Created February 24, 2012 05:01
Show Gist options
  • Save ponkichi7/1897895 to your computer and use it in GitHub Desktop.
Save ponkichi7/1897895 to your computer and use it in GitHub Desktop.
Gradle to run Java and Groovy
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