Skip to content

Instantly share code, notes, and snippets.

@tomgullo
Last active September 17, 2015 20:24
Show Gist options
  • Save tomgullo/8952461 to your computer and use it in GitHub Desktop.
Save tomgullo/8952461 to your computer and use it in GitHub Desktop.
run groovy in gradle
//You can create src/main/groovy, put your script called 'myscript.groovy' in there:
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'application'
configurations {
excludeFromJar
compile.extendsFrom excludeFromJar
}
repositories {
mavenCentral()
}
dependencies {
excludeFromJar 'donotincludeinjar'
compile 'org.codehaus.groovy:groovy-all:2.0.5'
}
task runScript (dependsOn: 'classes', type: JavaExec) {
main = 'myscript'
classpath = sourceSets.main.runtimeClasspath
}
task uberJar(dependsOn: 'classes', type:'Jar') {
dependsOn configurations.runtime
from files(sourceSets.main.output.classesDir)
from {
(configurations.runtime - configurations.excludeFromJar).collect {
it.isDirectory() ? it : zipTree(it)
}
}
mainfest {
attributes 'Main-Class': 'MyMainClass'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment