Skip to content

Instantly share code, notes, and snippets.

@leewin12
Created September 10, 2013 06:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leewin12/6505726 to your computer and use it in GitHub Desktop.
Save leewin12/6505726 to your computer and use it in GitHub Desktop.
org.bouncycastle + maven shade
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.x</groupId>
<artifactId>y</artifactId>
<name>z</name>
<packaging>jar</packaging>
<version>1.0.0</version>
<properties>
<org.jasypt-version>1.9.0</org.jasypt-version>
</properties>
<dependencies>
<!-- crypto Util -->
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
<version>${org.jasypt-version}</version>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt-hibernate3</artifactId>
<version>${org.jasypt-version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk16</artifactId>
<version>1.46</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<!-- Build jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.x.y.Main</mainClass>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.tooling</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@nigel-v-thomas
Copy link

Perfect, thanks for sharing this!

@rasanka
Copy link

rasanka commented Aug 25, 2017

Hi, Thanks for sharing this. I was able to generate the jar file.
However It seems that it's not including all the dependencies for bouncycastle
In my case the program was unable to do the PGP encryption. failing with the exception encrypting session key
Please update if you have any idea about this.

Thanks

@mwarner1
Copy link

Not sure if this the same issue, but extracting BouncyCastle like this seems to break the signature required by JCE. I am getting:

"Exception in thread "main" java.security.NoSuchProviderException: JCE cannot authenticate the provider BC

I found this thread that seems to imply that using maven shading might be the problem:
https://stackoverflow.com/questions/13721579/jce-cannot-authenticate-the-provider-bc-in-java-swing-application

@leewin12
Copy link
Author

leewin12 commented Nov 15, 2017

@rasanka sorry, I have no idea about that problem.
@mwarner1 thank you for sharing experience.

@herbertpimentel
Copy link

@mwarner1 I am facing exactly this problem your reported. Do you know any workaround for this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment