java - Exclude BouncyCastle jar but include everything else in a fat jar -


because bouncycastle jars signed , using jar-with-dependencies in maven-assembly-plugin destroy these signature, know if possible create kind of output :

  • my code , every dependencies in fat jar, excluding bc jar
  • the bc jar in lib/ subfolder

i manage exclude bc jar in fat jar using assembly file looking :

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> <id>jar-with-dependencies</id> <formats>     <format>jar</format> </formats> <includebasedirectory>false</includebasedirectory> <dependencysets>     <dependencyset>         <outputdirectory>/</outputdirectory>         <unpack>true</unpack>         <excludes>             <exclude>org.bouncycastle:bcprov-jdk15on</exclude>         </excludes>     </dependencyset> </dependencysets> 

now, how can tell maven-assembly-plugin put bc jar standalone jar in lib/ folder still reference in manifest file ?

best regards.

edit : tried following (not clean wanted, if works, enough) :

i exclude bc jar assembly, , add custom class-path injection in maven archiver section of maven-assembly-plugin :

<plugin>             <groupid>org.apache.maven.plugins</groupid>             <artifactid>maven-assembly-plugin</artifactid>             <version>3.1.0</version>             <configuration>                 <appendassemblyid>false</appendassemblyid>                 <descriptors>                     <descriptor>src/main/assembly/jar.xml</descriptor>                 </descriptors>                 <archive>                     <manifest>                         <mainclass>${mainclass}</mainclass>                         <adddefaultimplementationentries>true</adddefaultimplementationentries>                     </manifest>                     <manifestentries>                         <class-path>lib/bcprov-jdk15on.jar</class-path>                     </manifestentries>                 </archive>                 <outputdirectory>${staging.dir}</outputdirectory>             </configuration>             <executions>                 <execution>                     <phase>package</phase>                     <goals>                         <goal>single</goal>                     </goals>                 </execution>             </executions>         </plugin> 

the manifest file modified expected :

manifest-version: 1.0 implementation-title: mycode implementation-version: 2.0.27.3 built-by: ixo implementation-vendor-id: my.package class-path: lib/bcprov-jdk15on.jar created-by: apache maven 3.3.9 build-jdk: 1.8.0_144 implementation-vendor: foo main-class: my.package.main 

but jvm doesn't seems take class-path entry account, don't understand why

edit 2 : ok, found why previous edit don't works, maven-assembly-plugin generate index.list file, , if file present, used instead of manifest.mf, , because add bc jar overriding class path in maven-archiver section, index.list wrong. disabling indexing doesn't works if using fat jar generation.

ok, here dirty solution, not proud of it, , if can post better one, gladly up-vote solution.

here step make fat jar bc jar(s) outside :

  1. create assembly file exclude bc dependencies want <exclude>org.bouncycastle:bcprov-jdk15on</exclude>
  2. use maven archiver append custom class-path entries in manifest.mf file <manifestentries><class-path>lib/bcprov-jdk15on-1.57.jar</class-path></manifestentries>
  3. use truezip-maven-plugin remove index.list file fat jar

there done.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -