zoukankan      html  css  js  c++  java
  • 用gradle打包可运行jar

    参考了

    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
  • 相关阅读:
    Linux 配置gitee
    Linux C errno出错处理
    Linux C进程时间:墙上时钟时间,用户CPU时间,系统CPU时钟时间
    编译错误: 对‘aio_read’未定义的引用
    Linux 异步IO(AIO)
    Linux getaddrinfo获得本机ip地址为何127.0.1.1?
    Linux 文件截断的几种方式
    如何创建守护进程?
    守护进程, 协同进程, 僵尸进程, 孤儿进程概念理解
    对线程安全, 可重入函数, 异步安全的理解
  • 原文地址:https://www.cnblogs.com/devilwind/p/8651125.html
Copyright © 2011-2022 走看看