This is my gradle build script.
apply plugin: 'groovy' project.group = "test.tree" archivesBaseName = "tree" project.version = "1.0" manifest.mainAttributes("Main-Class" : "test.tree.App") sourceCompatibility=1.6 targetCompatibility=1.6 repositories { mavenCentral() } dependencies { groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.8.6' testCompile group: 'junit', name: 'junit', version: '4.8.2' }
And this compiles just fine
The problem is that I can't run the created JAR, I get an exception java.lang.NoClassDefFoundError: groovy/lang/GroovyObject
So I guess the groovy plugin doesn't include all the necessary classes inside the JAR.
How to I create a stand-alone JAR that I can simply .. run ;-)
What you are looking for is the application plugin which allows you build a standalone JVM application including all dependencies and run scripts.
apply plugin:'application' mainClassName = 'test.tree.App'
EDIT:
This should create the uberjar you want:
task uberjar(type: Jar) { from files(sourceSets.main.output.classesDir) from configurations.runtime.asFileTree.files.collect { zipTree(it) } manifest { attributes 'Main-Class': 'test.tree.App' } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With