Skip to content

Fix #393: stop reading LATEST from the deprecated Artifact constant - #424

Merged
elharo merged 2 commits into
apache:masterfrom
kratos0718:fix-393-deprecated-latest-version
Aug 20, 2026
Merged

Fix #393: stop reading LATEST from the deprecated Artifact constant#424
elharo merged 2 commits into
apache:masterfrom
kratos0718:fix-393-deprecated-latest-version

Conversation

@kratos0718

@kratos0718 kratos0718 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #393.

getAetherArtifact() filled in a missing version from org.apache.maven.artifact.Artifact.LATEST_VERSION, which Maven 4 deprecates. That import was the only use of the class, so it goes too. The value stays "LATEST", now a private constant on the mojo.

One thing on the issue's suggested replacement: null does not work here. Aether normalises it to the empty string, not to a metaversion.

new DefaultArtifact("g", "a", "jar", (String) null).getVersion()   // ""
new DefaultArtifact("g", "a", "jar", "LATEST").getVersion()        // "LATEST"

(checked against maven-resolver-api 2.0.21). The result goes straight into readArtifactDescriptor and resolveArtifact, so an empty version would make help:effective-pom -Dartifact=groupId:artifactId look for g:a:pom: instead of the newest release.

getAetherArtifact had no tests, so this adds four covering the two-part and three-part forms and the two rejection paths. The metaversion assertion uses the literal rather than the constant, so it still fails if the value changes. mvn test is 30 passing, spotless clean.


…tant

getAetherArtifact() filled in a missing version from
org.apache.maven.artifact.Artifact.LATEST_VERSION, which Maven 4
deprecates, and that import was the only thing the class used it for.

The value stays "LATEST", now a private constant. Passing null instead,
as the issue suggests, would not work: Aether's DefaultArtifact normalises
a null version to the empty string, so two-part coordinates would resolve
against g:a:pom: rather than the newest version.

Adds a test for the coordinate parsing, which had none.

@elharo elharo left a comment

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.

license not agreed to

Comment thread src/main/java/org/apache/maven/plugins/help/AbstractHelpMojo.java Outdated
@kratos0718

Copy link
Copy Markdown
Contributor Author

Both addressed — the constant is inlined at the use site, and the licence box is ticked. Ready for another look when you have a moment @elharo.

* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0

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.

https

@kratos0718

Copy link
Copy Markdown
Contributor Author

On the https note — I tried it and spotless rejects it. The licence header is a fixed template in the build, so changing the scheme fails the check and spotless:apply rewrites it straight back:

[ERROR] The following files had format violations:
[ERROR]     src/test/java/org/apache/maven/plugins/help/AbstractHelpMojoTest.java
[ERROR]         -·*···https://www.apache.org/licenses/LICENSE-2.0
[ERROR]         +·*···http://www.apache.org/licenses/LICENSE-2.0

All 147 source files in the repo carry the http form, so this one matches. Changing it looks like a spotless config change rather than something to do in this PR — happy to raise it separately if you want it moved.

@elharo elharo left a comment

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.

OK< we need to fix spotless then but not in this PR

@elharo
elharo merged commit 2dbc5ee into apache:master Aug 20, 2026
17 checks passed
@github-actions github-actions Bot added this to the 3.5.3 milestone Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AbstractHelpMojo.getAetherArtifact() uses deprecated Artifact.LATEST_VERSION

2 participants