spdx / Spdx-Java-Library

Java library which implements the Java object model for SPDX and provides useful helper functions
Apache License 2.0
35 stars 33 forks source link

Add Automatic-Module-Name entry to jar manifest #192

Closed JohnnyJayJay closed 1 year ago

JohnnyJayJay commented 1 year ago

This PR adds a the Automatic-Module-Name manifest entry, making it easier for modular projects (Java 9 and above) to include this library. I've given the name org.spdx.library to the module, this can of course be changed if desired.

goneall commented 1 year ago

Thanks @JohnnyJayJay - I have not used Java modules in my projects to date, but the change seems reasonable. It looks like the name we use is quite important since we really shouldn't change it in the future.

I think the proposed name is correct since this will always be assumed to be "Java" and matches the naming conventions for the packages.

The other name to consider would be org.spdx.java.library which would be consistent with the Git repo naming convention which houses several different computer language libraries.

As mentioned above, I currently prefer the proposed org.spdx.library but wanted to check with you to see if there would be a future scenario where the module name may be used in a non-Java context.

JohnnyJayJay commented 1 year ago

Cheers, thank you for the quick response. You're right, the module name should be final. But unless there is any other Java project that could reasonably be put under org.spdx.library, this should be good enough. Usually I'd use the "root package" of the project, but there isn't really one here aside from org.spdx which is a bit too general.

I have not used Java modules in my projects to date

They're quite useful for application development. As it stands, this library actually already gets an automatic module name (spdx.java.library) which is just derived from the jar file. Such names are generally considered unstable and people are discouraged from making modules depending on them, which is why setting an explicit name is good. Without doing that, Gradle actually won't accept the library as a module at all (and it becomes very annoying to build a modular application), so that's the main reason I'm making this PR.