-
Notifications
You must be signed in to change notification settings - Fork 38
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
Consider adding a module descriptor #296
Comments
@rfscholte - can you provide a bit more specifics on a recommended approach? We would like to continue to support Java 8 which doesn't support modules, at the same time we would like to support proper module naming as introduced with this pull request: #192 Is the solution to add a module.info file to the dependencies (e.g. spdx-java-core, spdx-java-model-2_X, and spdx-java-model-3_0)? I haven't used modules in the past, so any advice is much appreciated. |
(based on @rfscholte and @goneall comments and some research: ) In this case, Maven is trying to determine the name of the unnamed module based on the JAR filename (spdx-java-model-2_X-1.0.0-RC2.jar).
The issue here is, each part of the module name must be a valid Java identifier name -- but One of the way to fix this particular module naming issue is to change the JAR name to -- But ideally, and by convention, the module name should be in a reverse DNS fashion. #192 agrees that this should be Based on the current directory structure/package name, the module name for To achieve that, we have to explicitly name the module.
Another way is to put the module name inside The content of module org.spdx.library.model.v2 {
exports org.spdx.library.model.v2;
exports org.spdx.library.referencetype;
exports org.spdx.storage.compatv2;
requires transitive org.spdx.core;
requires transitive org.spdx.storage;
} If we can do this with all -- However, the code base with I'm not sure if we can use Maven build profiles to include/exclude @rfscholte please correct me / add anything. I never use modules as well. Thank you. |
That's indeed quite a complete and correct analysis. A view things to add to that: Maven just passes the files to Java, asking for it's module name. Profiles are useful for different Java runtimes for Maven. Back in the days of Java 9 that approach would make sense because some code could not be compiled with Java 9 yet. But currently most projects are running Maven with at least Java 11 without any uses, even to create Java 8 compatible code. What I would do is the following:
Looking at model-2_X:
This tells me you should not add the module-info.java yet, because I'm pretty sure jsr350 will not be the modulename. |
Thanks @rfscholte @bact - I'll work on a PR based on the suggestions |
From reading this article, it looks like adding the I'd like to leave this issue open to either implement the module descriptor once we have to drop support for Java 8 or we implement a more sophisticated CI. @bact @rfscholte - Thanks again for the advice and pointers. If you disagree with the approach, I'll need a bit more help in constructing the PR which includes all the necessary tests and changes. |
@bact @rfscholte - Please review the following PR's:
This now generates the following dependencies:
|
Please review the module name addition in org.spdx.v3jsonldstore |
Currently state of this library is like this:
If a line ends with (auto), the module name is based on the filename
If a line ends with [auto], the module name is the Automatic-Module-Name entry of the META-INF/MANIFEST.MF
All others are explicit modules (containing a module-info.class)
Once it is structured as a valid module (e.g. no split packages with other modules), you could add the Automatic-Module-Name entry in the META-INF/MANIFEST.MF for this project.
Once all modules are explicit (no more automatic modules), you can also add the module-info.java to this project.
The text was updated successfully, but these errors were encountered: