The answer by @felix almost brought me there. I had two issues:
With Gradle 1.5, the manifest tag was not recognised inside the fatJar task, so the Main-Class attribute could not directly be set
the jar had conflicting external META-INF files.
The following setup resolves this
jar { manifest { attributes( 'Main-Class': 'my.project.main', ) } } task fatJar(type: Jar) { manifest.from jar.manifest classifier = 'all' from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } } { exclude "META-INF/*.SF" exclude "META-INF/*.DSA" exclude "META-INF/*.RSA" } with jar }
To add this to the standard assemble or build task, add:
artifacts { archives fatJar }
出自http://stackoverflow.com/questions/4871656/using-gradle-to-build-a-jar-with-dependencies#
本博客所有文章如无特别注明均为原创。作者:nevergreen ,复制或转载请以超链接形式注明转自 。
原文地址《Using Gradle to build a jar with dependencies》
原文地址《Using Gradle to build a jar with dependencies》