gradle编译java签名,在Gradle Build中删除Jar签名

We are having an issue with a war built from gradle failing to load in tomcat because of a Security Exception specific to a signed Jar. The stack trace is not showing what jar is causing the problem and to get this thing running I'm wondering if I can exclude the signatures in the build when the war is getting built but don't know how to do that with Gradle. In maven I believe it would be a tag but not sure if this type of thing is available in Gradle. Any input would be appreciated, the Exception being thrown is below.

Caused by: java.lang.SecurityException: Invalid signature file digest for

解决方案

To find out if a jar file is signed, you can unzip the jar file using any zip utility tool. If the jar is signed it will contain files like *.RSA, *.SF or *.DSA under META-INF folder.

To exclude these signature files in gradle build , I did the following in my build.gradle. If you are using any other plugin to create the jar than you should check that plugins documentation for more details.

jar {

from { (configurations.runtime).collect { it.isDirectory() ? it : zipTree(it) } } {

exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'

}

manifest {

attributes("Main-Class": "com.nk.social.shareit.streams.AppMain")

}}

My entire build.gradle file is as listed below:-

apply plugin: 'scala'

dependencies {

compile group: 'org.apache.kafka', name: 'kafka-streams', version: '0.11.0.1'

compile 'org.scala-lang:scala-library:2.12.2'

compile 'com.sksamuel.elastic4s:elastic4s-core_2.12:5.4.2'

compile 'com.sksamuel.elastic4s:elastic4s-http_2.12:5.4.2'

compile 'org.apache.lucene:lucene-core:6.5.1'

compile 'joda-time:joda-time:2.9.9'

testCompile group: 'org.scalatest', name: 'scalatest_2.12', version: '3.0.4'

}

jar {

from { (configurations.runtime).collect { it.isDirectory() ? it : zipTree(it) } } {

exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'

}

manifest {

attributes("Main-Class": "com.nk.social.shareit.streams.AppMain")

}

}

Hope this helps.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值