Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shading to -fat.jar #9

Closed
ravenAtSafe opened this issue Mar 28, 2024 · 7 comments
Closed

Add shading to -fat.jar #9

ravenAtSafe opened this issue Mar 28, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@ravenAtSafe
Copy link

The new fat jar added in #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
@spannm
Copy link
Owner

spannm commented Mar 30, 2024

Hi @ravenAtSafe,

please take another look at the latest available snapshots and give the fat jar a spin.
I think it might come pretty close to what you're looking for.
Looking forward to your feedback.

Happy Easter, everyone!!

@ravenAtSafe
Copy link
Author

ravenAtSafe commented Apr 1, 2024

Hmmm, after inspecting ucanaccess-5.1.2-20240328.080123-2-fat.jar I'm not sure if we're getting closer (to what we build locally) or not

  • org.apache.commons appears to be missing now
    • it's possible this is only needed by encryption though?
  • org/hsqldb still not shaded
  • no sign of jackcess-encrypt
    • jackcess/cryptmodel
    • org/bouncycastle
    • other?

To be clear, we already have a perfectly viable local build solution but it seems like other users might get value out of a stock jar that fills that niche. I will not object if you choose not to pursue.

@spannm
Copy link
Owner

spannm commented Apr 5, 2024

I've added jackcess-encrypt and transitive dependencies to fat jar (unfortunately this leads to a much larger jar mostly due to bouncycastle).

Correct, Apache Commons logging and lang3 are dependencies of jackcess-encrypt only, even though jackcess-encrypt pulls them in through the legacy (not forked) jackcess.

In order to do this right, jackcess-encrypt would need to get forked as well (to remove dependencies on Apache Commons for one reason), so this is turning into quite a bit of work.

Regarding shading, what are your expectations for renaming packages, more precisely, which to rename and which not to rename? Ucanaccess jar itself IMO should not be shaded as it is a driver (not a library), driver name as well as main class (console) must remain untouched.

@ravenAtSafe
Copy link
Author

Regarding shading, what are your expectations for renaming packages, more precisely, which to rename and which not to rename?

We shade everything except for the ucanaccess driver itself.

@spannm
Copy link
Owner

spannm commented Apr 14, 2024

@ravenAtSafe Please see the comment posted in issue #7 and review

@ravenAtSafe
Copy link
Author

If you intended jackcess-encrypt and friends to remain outside the UBER jar (.zip /lib folder) then this looks complete to me 👍

@spannm spannm self-assigned this Oct 30, 2024
@spannm spannm added the enhancement New feature or request label Oct 30, 2024
@spannm
Copy link
Owner

spannm commented Oct 31, 2024

Fixed in release 5.1.2

@spannm spannm closed this as completed Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants