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

Automatic-Module-Name is undefined in MANIFEST file #1239

Closed
leadpony opened this issue Nov 3, 2023 · 4 comments · Fixed by #1240
Closed

Automatic-Module-Name is undefined in MANIFEST file #1239

leadpony opened this issue Nov 3, 2023 · 4 comments · Fixed by #1240

Comments

@leadpony
Copy link
Contributor

leadpony commented Nov 3, 2023

The artifacts in my project are JPMS (Java Platform Module System) modules and one of them depends on AsciiDoctorJ API. It works fine with both the stable 2.5.10 and the latest 3.0.0-alpha-1.

module-info.java in my module is like this.

module my.module {
    requires asciidoctorj.api;
}

Building this module using Maven emmits the following message:

[INFO] Required filename-based automodules detected: [asciidoctorj-api-3.0.0-alpha.1.jar]. Please don't publish this project to a public artifact repository!

This message prevents me from publishing my module to the Maven Central.

Fixing this problem is very easy. It just requires to add Automatic-Module-Name attribute in the build.gradle in asciidoctorj-api project to name the automatic module explicitly:

jar {
  bnd(
    'Bundle-Name': 'asciidoctorj-api',
    'Bundle-SymbolicName': 'org.asciidoctor.asciidoctorj-api',
    'Automatic-Module-Name': 'org.asciidoctor.asciidoctorj.api'
  )
}

This does harm nothing when JVM is running without module path.

Please note that the name given for the automatic module illustrated above is simply constructed with the group ID and the artifact ID replacing - with .. You can change it if there is more appropriate name for this project.

Please also see this excellent article:
Automatic-Module-Name: Calling all Java Library Maintainers

@robertpanzer
Copy link
Member

Thanks for the issue!
I am fine with the names asciidoctorj.api, asciidoctorj.core etc.
About your example I'd prefer to not put it into the configuration of the bnd plugin. Its purpose is for building OSGi modules, and I think it might be confusing to find that property there.

For 3.0 I'd prefer to also add proper module-info files that also declare the dependencies.

@leadpony
Copy link
Contributor Author

leadpony commented Nov 5, 2023

@robertpanzer

Thank you for your reply.

I am fine with the names asciidoctorj.api, asciidoctorj.core etc.

Which one you mean?

  1. asciidoctorj.api
  2. org.asciidoctor.asciidoctorj.api

Module names must be globally unique and traditionally the reverse DNS notation is used to secure the uniqueness.

Its purpose is for building OSGi modules, and I think it might be confusing to find that property there.

I agree.

My request is:

  1. Reserve a module name for future modularization of AsciidoctorJ.
  2. Add it to the MANIFEST.MF for library users.

The following sentense is from the book Java 9 Modularity published by O'Reilly:

Reserving a module name with Automatic-Module-Name in the manifest is something
you should do as quickly as possible.

My request is not about the full modularization equipped with a module descriptor, bacause it takes long time as in the issue #1036, which seems to be posted 2 years ago.

@robertpanzer
Copy link
Member

If I understand correctly the current automatic module names would be asciidoctorj.api and asciidoctorj.
Changing that to org.asciidoctor.asciidoctorj.api would be a breaking change imo, since AsciidoctorJ should work with JPMS atm and users might already be relying on that.

We can consider the move to org.asciidoctor.asciidoctorj.api for AsciidoctorJ 3.0, but not for 2.5.x.

@leadpony
Copy link
Contributor Author

leadpony commented Nov 5, 2023

Yes, you are right.

Currently the users of AsciidoctorJ are using filename-based, non-canonical module names because the library lacks Automatic-Module-Name entries in the manifest.

I hope that 3.0.0-alpha.2 contains the modification to the manifest files.

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 a pull request may close this issue.

2 participants