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

Make more compatible with JPMS #154

Merged
merged 1 commit into from
Jul 27, 2024
Merged

Conversation

nea89o
Copy link
Contributor

@nea89o nea89o commented Jul 22, 2024

There are a few problems relating to JPMS support:

  • Transitive dependencies of the beautifier web jar are pulled in. In practice only the beautifier itself (actually just one file of that JAR, the compiled beautifier.js) is needed. (This is not actually a JPMS issue, but i thought i'd change it while i am already changing the build script)
    image
  • If this library gets loaded as a JPMS module (that was manually upgraded, or automatically via a buildsystem) it will not have access to the resources of other modules, which includes the beautifier web jar. This can be fixed by directly accessing the classloader in JsSanitizer (since resources accessed through the class loader are not module specific):
- 					new BufferedInputStream(JsSanitizer.class.getResourceAsStream(BEAUTIFY_JS)), StandardCharsets.UTF_8))) {
+					new BufferedInputStream(JsSanitizer.class.getClassLoader().getResourceAsStream(BEAUTIFY_JS)), StandardCharsets.UTF_8))) {
  • Lastly this package is not a JPMS module, but can also not be included as a JPMS module in gradle due to a shortcoming of gradles automatic module support (https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_modular). A non-invasive fix for this is to add a Automatic-Module-Name attribute to the MANIFEST.MF which will allow gradle to generate a module-info.java if the project requires this, while not adding any module-info for projects that dont already make use of it.

@mxro mxro merged commit 74d6558 into javadelight:master Jul 27, 2024
1 check passed
@mxro
Copy link
Collaborator

mxro commented Jul 27, 2024

Great work! Thanks for the pull request! Will build the next release including this now!

@mxro
Copy link
Collaborator

mxro commented Jul 27, 2024

Released with 0.4.3

@nea89o nea89o deleted the feat/jpmscompat branch July 27, 2024 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants