参考了
http://www.cnblogs.com/yongtao/p/4104526.html
gradle文件加入
apply plugin: 'application'
mainClassName = 'com.xxx.Xxx'
//打包 task runnbaleJar(type: Jar) { from files(sourceSets.main.output.classesDir) from configurations.runtime.asFileTree.files.collect { zipTree(it) } manifest { attributes 'Main-Class':'com.Sayer' } }
作者:bsqql123
链接:https://www.jianshu.com/p/4d5c82d80041
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
//打包 task runnbaleJar(type: Jar) { from files(sourceSets.main.output.classesDir) from configurations.runtime.asFileTree.files.collect { zipTree(it) } manifest { attributes 'Main-Class':'com.Sayer' } }//打包 task runnbaleJar(type: Jar) { from files(sourceSets.main.output.classesDir) from configurations.runtime.asFileTree.files.collect { zipTree(it) } manifest { attributes 'Main-Class':'com.Sayer' } }
作者:bsqql123
链接:https://www.jianshu.com/p/4d5c82d80041
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
task runnbaleJar(type: Jar) {
from files(sourceSets.main.output.classesDir)
from configurations.runtime.asFileTree.files.collect { zipTree(it) }
manifest { attributes 'Main-Class':'com.xxx.Xxx' }
exclude('LICENSE.txt', 'NOTICE.txt', 'rootdoc.txt')
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
exclude 'META-INF/NOTICE', 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE', 'META-INF/LICENSE.txt'
exclude 'META-INF/DEPENDENCIES'
} exclude 这些必须加上,不然打包出来的jar 无法运行,会报invalid signature file degist for manifest
在另外一篇用maven打包的也提及过此问题 https://www.cnblogs.com/fuxinci/p/3356087.html