-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Defining Java Jigsaw modules (JPMS) #785
Comments
I'm ok to open a pull request. I'm just waiting feedback before going further. |
## Summary The goal of this change is to encourage Gradle to put the framework's Jar files in the module path instead of the classpath. For that, we need to explicitly define the `Automatic-Module-Name` attribute in the `MANIFEST.MF` files in framework's Jar files (source: https://docs.gradle.org/current/userguide/java_library_plugin.html#using_libraries_that_are_not_modules). The newly added attribute follows this format: `<groupId>.<jarBaseName>` (e.g. `org.incendo.cloud-core`). ## Impact There is no impact nor on maintainer side nor or consumer one not relying on JPMS. For the ones already relying on JPMS (e.g. Maven users), they will just have to adapt the references in their `module-info.java` files as follow: From: ```java module my.module { [...] requires cloud-core; [...] } ``` To: ```java module my.module { [...] requires org.incendo.cloud-core; [...] } ``` Closes Incendo#785
## Summary The goal of this change is to encourage Gradle to put the framework's Jar files in the module path instead of the classpath. For that, we need to explicitly define the `Automatic-Module-Name` attribute in the `MANIFEST.MF` files in framework's Jar files (source: https://docs.gradle.org/current/userguide/java_library_plugin.html#using_libraries_that_are_not_modules). The newly added attribute follows this format: `<groupId>.<jarBaseName>` (e.g. `org.incendo.cloud-core`). Details about this change can be found here: Incendo#785. ## Impact There is no impact nor on maintainer side nor or consumer one not relying on JPMS. For the ones already relying on JPMS (e.g. Maven users), they will just have to adapt the references in their `module-info.java` files as follow: From: ```java module my.module { [...] requires cloud-core; [...] } ``` To: ```java module my.module { [...] requires org.incendo.cloud-core; [...] } ``` Closes Incendo#785
_This change is similar to https://github.com/Incendo/cloud/pull/787_ ## Summary The goal of this change is to encourage Gradle to put the framework's Jar files in the module path instead of the classpath. For that, we need to explicitly define the `Automatic-Module-Name` attribute in the `MANIFEST.MF` files in framework's Jar files (source: https://docs.gradle.org/current/userguide/java_library_plugin.html#using_libraries_that_are_not_modules). The newly added attribute follows this format: `<groupId>.<jarBaseName>` (e.g. `org.incendo.cloud-paper`). Details about this change can be found here: Incendo/cloud#785. ## Impact There is no impact nor on maintainer side nor or consumer one not relying on JPMS. For the ones already relying on JPMS (e.g. Maven users), they will just have to adapt the references in their `module-info.java` files as follow: From: ```java module my.module { [...] requires cloud-paper; [...] } ``` To: ```java module my.module { [...] requires org.incendo.cloud-paper; [...] } ```
After a discussion with Citymonstret on Discord, he said being open for such change as long as it doesn't impact negatively the project's maintainability. For the time being, I opened two PRs proposing the easier and less risky solution to implement: Basically, we just add a manifest attribute in Jar files: the Can you have a look on these two PRs please? |
## Summary The goal of this change is to encourage Gradle to put the framework's Jar files in the module path instead of the classpath. For that, we need to explicitly define the `Automatic-Module-Name` attribute in the `MANIFEST.MF` files in framework's Jar files (source: https://docs.gradle.org/current/userguide/java_library_plugin.html#using_libraries_that_are_not_modules). The newly added attribute follows this format: `<groupId>.<jarBaseName>` (e.g. `org.incendo.cloud-core`). Details about this change can be found here: Incendo#785. ## Impact There is no impact nor on maintainer side nor or consumer one not relying on JPMS. For the ones already relying on JPMS (e.g. Maven users), they will just have to adapt the references in their `module-info.java` files as follow: From: ```java module my.module { [...] requires cloud-core; [...] } ``` To: ```java module my.module { [...] requires org.incendo.cloud-core; [...] } ``` Closes Incendo#785
_This change is similar to https://github.com/Incendo/cloud/pull/787_ ## Summary The goal of this change is to encourage Gradle to put the framework's Jar files in the module path instead of the classpath. For that, we need to explicitly define the `Automatic-Module-Name` attribute in the `MANIFEST.MF` files in framework's Jar files (source: https://docs.gradle.org/current/userguide/java_library_plugin.html#using_libraries_that_are_not_modules). The newly added attribute follows this format: `<groupId>.<jarBaseName>` (e.g. `org.incendo.cloud-paper`). Details about this change can be found here: Incendo/cloud#785. ## Impact There is no impact nor on maintainer side nor or consumer one not relying on JPMS. For the ones already relying on JPMS (e.g. Maven users), they will just have to adapt the references in their `module-info.java` files as follow: From: ```java module my.module { [...] requires cloud-paper; [...] } ``` To: ```java module my.module { [...] requires org.incendo.cloud-paper; [...] } ```
## Summary The goal of this change is to encourage Gradle to put the framework's Jar files in the module path instead of the classpath. For that, we need to explicitly define the `Automatic-Module-Name` attribute in the `MANIFEST.MF` files in framework's Jar files (source: https://docs.gradle.org/current/userguide/java_library_plugin.html#using_libraries_that_are_not_modules). The newly added attribute follows this format: `<groupId>.<moduleName>` (e.g. `org.incendo.cloud.core`). Details about this change can be found here: Incendo#785. ## Impact There is no impact nor on maintainer side nor or consumer one not relying on JPMS. For the ones already relying on JPMS (e.g. Maven users), they will just have to adapt the references in their `module-info.java` files as follow: From: ```java module my.module { [...] requires cloud.core; [...] } ``` To: ```java module my.module { [...] requires org.incendo.cloud.core; [...] } ``` Closes Incendo#785
_This change is similar to https://github.com/Incendo/cloud/pull/787_ ## Summary The goal of this change is to encourage Gradle to put the framework's Jar files in the module path instead of the classpath. For that, we need to explicitly define the `Automatic-Module-Name` attribute in the `MANIFEST.MF` files in framework's Jar files (source: https://docs.gradle.org/current/userguide/java_library_plugin.html#using_libraries_that_are_not_modules). The newly added attribute follows this format: `<groupId>.<moduleName>` (e.g. `org.incendo.cloud.paper`). Details about this change can be found here: Incendo/cloud#785. ## Impact There is no impact nor on maintainer side nor or consumer one not relying on JPMS. For the ones already relying on JPMS (e.g. Maven users), they will just have to adapt the references in their `module-info.java` files as follow: From: ```java module my.module { [...] requires cloud.paper; [...] } ``` To: ```java module my.module { [...] requires org.incendo.cloud.paper; [...] } ```
_This change is similar to https://github.com/Incendo/cloud/pull/787_ ## Summary The goal of this change is to encourage Gradle to put the framework's Jar files in the module path instead of the classpath. For that, we need to explicitly define the `Automatic-Module-Name` attribute in the `MANIFEST.MF` files in framework's Jar files (source: https://docs.gradle.org/current/userguide/java_library_plugin.html#using_libraries_that_are_not_modules). The newly added attribute follows this format: `<groupId>.<moduleName>` (e.g. `org.incendo.cloud.paper`). Details about this change can be found here: Incendo/cloud#785. ## Impact There is no impact nor on maintainer side nor or consumer one not relying on JPMS. For the ones already relying on JPMS (e.g. Maven users), they will just have to adapt the references in their `module-info.java` files as follow: From: ```java module my.module { [...] requires cloud.neoforge; [...] } ``` To: ```java module my.module { [...] requires org.incendo.cloud.neoforge; [...] } ```
Created PRs:
Please, any chance to get these PRs merged and to publish new versions of Cloud modules? |
The issue
The Jar files of the framework are not Jigsaw modules. Therefore, they are considered as "automatic" modules if put in the module path, or "unnamed" ones if put in the classpath instead.
When relying on Gradle, the Jar files are considered as "unnamed" ones, thus leading to troubles when trying to define our own modules depending on the Cloud framework (i.e. by describing the module through a
module-info.java
file). Here is a quote from the Gradle's documentation:It is worth to mention the fact an "application" module (i.e. a Jar file containing a module descriptor) can't depend on "unnamed" ones. This means that when defining a dependency to the Cloud framework in a
module-info.java
like that:We end up with the following Java error when trying to build the project with Gradle:
Even if an IDE like IntelliJ would not comply on its side since handling things differently. Thus, this proves that the framework's Jar files have not been included in the module path by Gradle.
Alternatives considered
One possibility is to adjust the Gradle's behavior at compilation time by adding the classpath in the module path, but that's not something that trivial to do nor convenient.
Relying on a Gradle plugin like extra-java-module-info may be the way to go even if not ideal. That's even more true in my case where I only have the issue with the Cloud framework.
Proposed solutions
Defining an automatic module name
One way to easily solve the issue with Gradle may be by simply defining the
Automatic-Module-Name
Jar manifest attribute:Which should lead to the following content in the
MANIFEST.MF
Jar's file:Instead of the following content as we have for the version 2.0.0:
However, it would be important to understand why the Gradle team decided to not automatically convert unnamed modules to automatic ones (reference). Especially:
Even if it seems we don't have risks regarding split-package issues:
It may still preferable to define module descriptors (
module-info.java
files).Defining module descriptors
This task may be less trivial and require more efforts.
Learning more about JPMS is required. A great guide on this front may be the Baeldung one.
The text was updated successfully, but these errors were encountered: