Skip to content

Derived automatic module name validation fails builds for non-modular projects since 3.4.2 #596

Description

@gnodet

Problem

maven-jar-plugin 3.4.2 validates the derived automatic module name (inferred from the artifact's Automatic-Module-Name manifest attribute or from the artifactId) even when it is not explicitly configured in the POM. If the derived name contains hyphens (which are not valid in Java module names), the build fails:

Error assembling JAR: Invalid automatic module name: 'org.apache.geronimo.arthur.integration-test'

This was not enforced in maven-jar-plugin 3.3.1. The stricter validation was introduced via maven-archiver in 3.4.2.

The check isValidModuleName() in maven-archiver's MavenArchiver now validates the derived module name, but many legitimate Apache projects have artifact IDs containing hyphens (e.g. integration-test, osgi-cdi) which produce invalid module names when derived mechanically. These projects do not intend to be JPMS modules and have no module-info.java.

Steps to reproduce

  1. Build a project whose artifactId (or Automatic-Module-Name manifest entry) contains a hyphen, e.g. my-artifact-integration-test.
  2. Use maven-jar-plugin 3.4.2.
  3. Build fails with Error assembling JAR: Invalid automatic module name: '...'.

Expected behavior

One of:

  • Only validate explicitly declared names: If Automatic-Module-Name is not set explicitly in the POM's <archive><manifestEntries>, do not fail — the derived name is merely informational for unnamed modules and does not need to be a valid JPMS module name.
  • Warn instead of fail: Emit a warning so the project is aware of the problem without breaking the build.

Affected versions

  • 3.4.2 (regression vs 3.3.1)

Context

Found while running Maven 4 compatibility tests across Apache projects. Affected projects include:

  • geronimo-arthur — derived name org.apache.geronimo.arthur.integration-test
  • incubator-kie-kogito-benchmarks — empty derived name
  • karaf-winegrower — derived name org.apache.winegrower.cepages.winegrower-cepage-osgi-cdi

None of these projects declare module-info.java or intend to be named JPMS modules.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions