Removing Jar Signatures in Gradle Build

前端 未结 1 527
野的像风
野的像风 2021-01-21 23:31

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 i

1条回答
  •  清歌不尽
    2021-01-22 00:18

    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.

    0 讨论(0)
提交回复
热议问题