在Gradle Build中删除Jar签名 [英] Removing Jar Signatures in Gradle Build

查看:420
本文介绍了在Gradle Build中删除Jar签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于特定于已签名Jar的安全异常,我们遇到了由gradle无法加载tomcat构建的war的问题。堆栈跟踪没有显示什么jar导致问题并且让这个东西运行我想知道我是否可以在战争构建时排除构建中的签名但是不知道如何使用Gradle执行此操作。在maven中我相信它将是一个< filter>< exclude> 标签,但不确定这种类型的东西是否在Gradle中可用。任何输入都将被欣赏,抛出异常是在下面。

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 <filter><exclude> 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 


推荐答案

要查明jar文件是否已签名,您可以使用任何zip实用工具解压缩jar文件。如果jar被签名,它将在META-INF文件夹下包含* .RSA,* .SF或* .DSA等文件。

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.

要在gradle构建中排除这些签名文件,我在build.gradle中执行了以下操作。如果您使用任何其他插件来创建jar,那么您应该检查插件文档以获取更多详细信息。

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")
}}

我的整个build.gradle文件如下所示: -

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")
    }
}

希望这会有所帮助。

这篇关于在Gradle Build中删除Jar签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆