Gradle - 将依赖和资源文件打入jar包
https://www.cnblogs.com/jyx140521/p/6855210.html
用以下build.gradle打包出来的jar包,依赖是分离的:
apply plugin: ‘java‘ dependencies { compile ‘commons-codec:commons-codec:1.4‘ compile ‘commons-logging:commons-logging:1.1.1‘ compile ‘com.google.code.gson:gson:2.4‘ compile ‘org.apache.httpcomponents:httpclient:4.3.6‘ compile ‘com.strategicgains:RestExpress:0.11.2‘ compile ‘com.fasterxml.jackson.core:jackson-databind:2.6.4‘ compile ‘com.fasterxml.jackson.core:jackson-core:2.6.4‘ compile ‘com.fasterxml.jackson.core:jackson-annotations:2.6.4‘ compile "ch.qos.logback:logback-core:1.1.3" compile "ch.qos.logback:logback-classic:1.1.3" compile ‘net.kencochrane.raven:raven-logback:6.0.0‘ compile ‘net.kencochrane.raven:raven:6.0.0‘ compile "org.slf4j:slf4j-api:1.7.13" compile ‘com.rabbitmq:amqp-client:4.1.0‘ compile ‘org.apache.commons:commons-lang3:3.4‘ compile ‘commons-net:commons-net:3.4‘ compile ‘org.zeromq:jeromq:0.3.5‘ compile fileTree(dir: ‘libs‘, include: [‘*.jar‘]) compile project(‘:tc-das‘) compile project(‘:result-compare‘) } jar { manifest { attributes( "Manifest-Version": 1.0, "Main-Class": "com.testbird.rio.Main", "Class-Path": configurations.compile.collect { "lib/${it.name}" }.join(‘ ‘)) } }
将build.gradle修改一下,就能将依赖和资源文件打入jar包了:
apply plugin: ‘java‘ dependencies { compile ‘commons-codec:commons-codec:1.4‘ compile ‘commons-logging:commons-logging:1.1.1‘ compile ‘com.google.code.gson:gson:2.4‘ compile ‘org.apache.httpcomponents:httpclient:4.3.6‘ compile ‘com.strategicgains:RestExpress:0.11.2‘ compile ‘com.fasterxml.jackson.core:jackson-databind:2.6.4‘ compile ‘com.fasterxml.jackson.core:jackson-core:2.6.4‘ compile ‘com.fasterxml.jackson.core:jackson-annotations:2.6.4‘ compile "ch.qos.logback:logback-core:1.1.3" compile "ch.qos.logback:logback-classic:1.1.3" compile ‘net.kencochrane.raven:raven-logback:6.0.0‘ compile ‘net.kencochrane.raven:raven:6.0.0‘ compile "org.slf4j:slf4j-api:1.7.13" compile ‘com.rabbitmq:amqp-client:4.1.0‘ compile ‘org.apache.commons:commons-lang3:3.4‘ compile ‘commons-net:commons-net:3.4‘ compile ‘org.zeromq:jeromq:0.3.5‘ compile fileTree(dir: ‘libs‘, include: [‘*.jar‘]) compile project(‘:tc-das‘) compile project(‘:result-compare‘) } jar { manifest { attributes( "Manifest-Version": 1.0, "Main-Class": "com.testbird.rio.Main") } from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } into(‘assets‘) { from ‘assets‘ } }
相关推荐
CaesarHome 2020-11-09
chenkai00 2020-07-26
CaptainCTR 2020-07-09
afa0 2020-06-23
StephenWong 2020-06-18
chenkai00 2020-06-13
Lucianoesu 2020-06-08
tysforwork 2020-06-05
貌似掉线 2020-05-30
tysforwork 2020-05-27
CaptainCTR 2020-05-07
CaptainCTR 2020-05-04
貌似掉线 2020-05-03
貌似掉线 2020-04-29
CaptainCTR 2020-04-23
jsonit 2020-04-23