Last active
September 17, 2015 20:24
-
-
Save tomgullo/8952461 to your computer and use it in GitHub Desktop.
run groovy in gradle
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
//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