Skip to content

Nuance the message about filename-based automodules detected on the module path#11857

Open
desruisseaux wants to merge 1 commit into
apache:masterfrom
Geomatys:nuance-automodule-warning
Open

Nuance the message about filename-based automodules detected on the module path#11857
desruisseaux wants to merge 1 commit into
apache:masterfrom
Geomatys:nuance-automodule-warning

Conversation

@desruisseaux
Copy link
Copy Markdown
Contributor

Instead of "Please don't publish this project to a public artifact repository", said "This project may not work in applications that do not use these dependencies with exactly the same filenames as listed above".

Rational: it can be considered okay to publish the project on a public Maven repository, because the artifact filenames are quite deterministic with Maven. For a pure-Maven project and for bundle generated by the Maven assembly plugin, there is no reason why these filenames would not be stable. Therefore, we can warn the users about the fragility of filename-based automodules but let them decide whether they want to publish anyway.

…odule path.

Instead of "Please don't publish this project to a public artifact repository",
said "This project may not work in applications that do not use these dependencies
with exactly the same filenames as listed above".
@desruisseaux desruisseaux added the java Pull requests that update Java code label Mar 28, 2026
@desruisseaux desruisseaux self-assigned this Mar 28, 2026
@desruisseaux desruisseaux requested a review from elharo March 28, 2026 16:05
@@ -236,7 +236,7 @@ public JavaPathType getPathType() {
/**
* If the module has no name, adds the filename of the JAR file in the given collection.
* This method should be invoked for dependencies placed on {@link JavaPathType#MODULES}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not new here, but this doc comment really is hard to follow or understand. It should be rewritten.

fileSeparator,
"Filename-based automodules detected on the module path: " + fileSeparator,
lineSeparator + "This project may not work in applications that do not use "
+ "these dependencies with exactly the same filenames as listed above.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only an issue when JPMS is used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is an issue if non-modular JARs are placed on the --module-path option. While not recommended, this is not forbidden neither in order to allow gradual transition, because the effect is not the same as keeping those JARs on --class-path. The javac tool already emits a warning for such cases, and developers may accept the risk if they understand the condition in which it works, which is to keep the JAR filenames unchanged.

Copy link
Copy Markdown
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code on behalf of Guillaume Nodet

The rationale is sound: the old message was overly prescriptive ("don't publish") when in practice Maven artifact filenames are deterministic. The new wording correctly shifts from a prohibition to an informational warning about the fragility.

Two minor observations below.

"Filename-based automodules detected on the module path: " + fileSeparator,
lineSeparator + "This project may not work in applications that do not use "
+ "these dependencies with exactly the same filenames as listed above.");
automodulesDetected.forEach(joiner::add);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new suffix is fairly long and may be hard to parse in a log. Consider shortening it slightly, e.g.:

Suggested change
automodulesDetected.forEach(joiner::add);
lineSeparator + "This project may not work if consumers use "
+ "these dependencies with different filenames.");

The original phrasing ("do not use these dependencies with exactly the same filenames as listed above") requires a double-negative mental parse ("not ... exactly the same"). "Different filenames" says the same thing more directly.

Feel free to ignore if you prefer the current wording.

* If the module has no name, adds the filename of the JAR file in the given collection.
* This method should be invoked for dependencies placed on {@link JavaPathType#MODULES}
* for preparing a warning asking to not deploy the build artifact on a public repository.
* for preparing a warning saying that this project may fail to resolve these modules.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the Javadoc on this method still says "for preparing a warning asking to not deploy the build artifact on a public repository", which no longer matches what the warning actually says. Should be updated to stay consistent with the new message.

Suggested change
* for preparing a warning saying that this project may fail to resolve these modules.
* for preparing a warning saying that this project may fail to resolve these modules.

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

Labels

java Pull requests that update Java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants