2

I have a Gradle project, which has plenty of dependencies from different repositories (mavenCentral, jcenter). After successful distZip task execution and inspecting a zip archive, I've found, that certain jars was duplicated in lib folder:

  1. bcprov-jdk14-1.38.jar and bcprov-jdk14-138.jar
  2. bcmail-jdk14-1.38.jar and bcmail-jdk14-138.jar

Jar tuples has the same size and content. I suppose this was happened because in different repositories those dependencies has different file names. How can I prevent jars duplication in zip file when performing distZip task? Could it be a default functionality for distZip task or some option to enable?

As a workaround I believe I can write some kind of distZip task handler and 'squeeze' dependencies jar tuples (which may have two, three and more copies) to leave just one using some Groovy scripting, but I wanna know is it a default solution?

Cœur
  • 37,241
  • 25
  • 195
  • 267
lospejos
  • 1,976
  • 3
  • 19
  • 35
  • My current suggestion is: 1) Find dependencies that has `bcmail` and `bcprov` transitive dependenies, especially if they are located in different repos; 2) add exclude directive for one of this dependencies - to exclude `bouncy castle` libraries. – lospejos Jul 23 '16 at 00:17
  • The problem like this is described here: http://stackoverflow.com/a/21315957/1828296 – lospejos Jul 23 '16 at 00:19

1 Answers1

2

As stated in https://stackoverflow.com/a/21315957/1828296, I found dependency which has transitive dependency to Bouncy castle libraries - it was com.lowagie:itext - by issuing gradle dependencies and searching by 1.38 and 138 values.

Then I made exclusions to this dependency like this:

compile ('com.lowagie:itext:2.1.7+') { exclude group: "bouncycastle" }

Also added newest Bouncy Castle versions:

compile 'org.bouncycastle:bcprov-jdk15on:1.54+' compile 'org.bouncycastle:bcmail-jdk15on:1.54+' compile 'org.bouncycastle:bctsp-jdk15on:1.46+' After distZip there was no old version or doubles of jars - just modern versions.

Community
  • 1
  • 1
lospejos
  • 1,976
  • 3
  • 19
  • 35