You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "Sekelenao (via GitHub)" <gi...@apache.org> on 2026/08/19 21:36:27 UTC

[I] [build] Shaded fat-JARs (fluss-client, fluss-flink, etc.) leak shaded module-info.class, breaking JPMS modular consumption [fluss]

Sekelenao opened a new issue, #4045:
URL: https://github.com/apache/fluss/issues/4045

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/fluss/issues) and found nothing similar.
   
   
   ### Fluss version
   
   main (development)
   
   ### Please describe the bug 🐞
   
   ## Problem Summary
   
   All shaded uber-JARs produced by Fluss (e.g. `fluss-client`, `fluss-flink-1.20`, `fluss-flink-1.19`, `fluss-server`) currently embed `META-INF/versions/9/module-info.class` originating from shaded dependencies (such as `commons-lang3:3.18.0` and `fluss-shaded-jackson`).
   
   As a result, on Java 9+, the Java Platform Module System (JPMS) treats these shaded JARs as the named module `org.apache.commons.lang3` rather than deriving an automatic module (e.g. `fluss.client`, `fluss.flink`).
   
   
   ## How to Reproduce
   
   Run `jar --describe-module` on any built shaded JAR (e.g., `fluss-client` or `fluss-flink-1.20`):
   
   ```bash
   jar --describe-module --file=fluss-client-1.0-SNAPSHOT.jar --release 21
   ```
   
   **Actual Output:**
   ```text
   releases: 9
   
   org.apache.commons.lang3@3.18.0 jar:file:///.../fluss-client-1.0-SNAPSHOT.jar!/META-INF/versions/9/module-info.class
   exports org.apache.commons.lang3
   exports org.apache.commons.lang3.arch
   ...
   requires java.base mandated
   requires java.desktop
   ```
   
   Notice that:
   1. The entire Fluss JAR is identified as module `org.apache.commons.lang3`.
   2. None of the `org.apache.fluss.*` packages are exported.
   
   
   ## Impact on Downstream Projects
   
   Downstream projects using the Java Module System (`module-info.java`) cannot access any Fluss APIs (`org.apache.fluss.client.*`, `org.apache.fluss.flink.*`, `org.apache.fluss.config.*`) without manually configuring awkward compiler flags such as:
   `--add-exports org.apache.commons.lang3/org.apache.fluss.client=<target-module>`
   
   ### Solution
   
   ## Solution Details
   
   In the root `pom.xml`, configure the global `maven-shade-plugin` filter (`<artifact>*</artifact>`) to exclude all `module-info.class` and multi-release `module-info.class` files:
   
   ```xml
   <filter>
       <artifact>*</artifact>
       <excludes>
           ...
           <!-- Do not copy module-info.class from shaded dependencies -->
           <exclude>module-info.class</exclude>
           <exclude>META-INF/versions/**/module-info.class</exclude>
           ...
       </excludes>
   </filter>
   ```
   
   This is the standard pattern used across Apache projects (Flink, Spark) when bundling shaded dependencies into uber-JARs.
   
   
   ## Local Validation
   
   I have tested this fix across multiple modules:
   - `fluss-client` now correctly derives `fluss.client@1.0-SNAPSHOT automatic` with all packages exported.
   - `fluss-flink-1.20` correctly derives `fluss.flink@1.20-1.0-SNAPSHOT automatic`.
   - `fluss-server` correctly derives `fluss.server@1.0-SNAPSHOT automatic`.
   - Spotless formatting (`mvn spotless:check`) and Checkstyle pass cleanly.
   
   I have this fix ready and tested locally, and would be very happy to submit a Pull Request if the maintainers approve this approach.
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@fluss.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org