ucanaccess
ucanaccess copied to clipboard
Add shading to -fat.jar
The new fat jar added in https://github.com/spannm/ucanaccess/issues/7 helpfully bundles all driver dependencies. For example, in ucanaccess-5.1.2-20240327.163958-57-fat.jar I can see
- com.zaxxer.sparsebits
- org.apache.commons
- org.hsqldb
As only one version of any Java class can be loaded it is likely that the ucanaccess driver will not be compatible with other jars that require different versions of those dependencies (either ucanaccess will be poisoned or it will poison others). This is true for the fat or standalone jars.
Adding shading to the fat jar would make ucanaccess a model citizen, safe from possible foreign interactions. This is what we do locally rather than using anything pre-built.
I believe the important bits of our own shading instructions (kinda crude, sorry) for rebuilding ucanaccess are the following (note that ucanaccess doesn't strictly need jackcess-encrypt but users do if they are dealing with encrypted databases - so I guess this request includes packing jackcess-encrypt in there).
d) in your maven project pom.xml, add dependencies to
- ucanaccess
https://central.sonatype.com/artifact/io.github.spannm/ucanaccess
- jackcess-encrypt (used by our code)
https://mvnrepository.com/artifact/com.healthmarketscience.jackcess/jackcess-encrypt
e) add maven-shade-plugin to pom.xml
f) view the dependency tree of the project via maven:
> mvn dependency:tree
g) inspect the dependency tree, and from top to bottom, add the artifacts that need to be included in your pom.xml
h) download these artifacts if your IDE hasn't automatically done so
i) inspect each artifact, determine the patterns that include the entire contents of the artifact (other than META-INF), and relocate them to jdbc.ucanaccess.shaded.* in your pom.xml
j) in your pom.xml, ensure that the project version (line 10) matches the version of ucanaccess that was added as a dependency in step d (line 15). (See FMEENGINE-63096)
k) package a JAR by running:
> mvn clean package