apache / apache/maven-jar-plugin
Derived automatic module name validation fails builds for non-modular projects since 3.4.2
- Dominant language
- Java
- Stars
- 92
- Forks
- 84
- Avg merge
- 19h 45m
- Merged PRs (30d)
- 6
Description
## 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 ``, 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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the maven-archiver MavenArchiver.isValidModuleName() check introduced for maven-jar-plugin 3.4.2, then reproduce the failure with an artifactId containing a hyphen and no module-info.java. Compare the behavior with 3.3.1 and determine whether derived names should be ignored or warned about; done means affected non-modular builds no longer fail unexpectedly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100