You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2026/09/18 06:58:45 UTC

[PR] [MJAR-596] Sanitize invalid Automatic-Module-Name instead of failing [maven-archiver]

gnodet opened a new pull request, #403:
URL: https://github.com/apache/maven-archiver/pull/403

   Fixes https://github.com/apache/maven-jar-plugin/issues/596
   
   Port of #402 to master.
   
   Projects that configure `Automatic-Module-Name` in `<archive><manifestEntries>` using a property derived from the artifactId (e.g. `${project.groupId}.${project.artifactId}`) can produce invalid JPMS module names when the artifactId contains hyphens. This previously caused a hard build failure with `ManifestException: Invalid automatic module name`.
   
   This change sanitizes the invalid name using the same algorithm the JDK applies when deriving an automatic module name from a JAR file name (`ModulePath.cleanModuleName()`): non-alphanumeric characters are replaced with `.`, repeated dots are collapsed, and leading/trailing dots are stripped. A warning is emitted so the user is aware.
   
   For example, `org.apache.geronimo.arthur.integration-test` becomes `org.apache.geronimo.arthur.integration.test`.
   
   If the sanitized name is still not a valid Java module name (e.g. starts with a digit, contains a keyword), the attribute is omitted with a warning — it cannot be fixed automatically in that case.
   
   Changes:
   - `MavenArchiver.java`: Add `cleanModuleName()` sanitization method; replace hard failure with sanitize-then-warn for invalid module names; only omit the attribute when sanitization still yields an invalid name
   - `MavenArchiverTest.java`: Updated tests to verify sanitization behavior; added `cleanModuleNames` parameterized test for the sanitization algorithm


-- 
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@maven.apache.org

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


Re: [PR] Sanitize invalid Automatic-Module-Name instead of failing [maven-archiver]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #403:
URL: https://github.com/apache/maven-archiver/pull/403


-- 
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@maven.apache.org

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