Repository navigation
Install the POM, not the JAR, for pom-packaged projects after jar:jar (#315) - #457
Conversation
…en jar:jar runs first When jar:jar is invoked on a pom-packaged project, it sets project.getArtifact().getFile() to the produced JAR. In InstallMojo.processProject(), when pomArtifact and projectArtifact have the same coordinates (pom packaging), the code was replacing pomArtifact with projectArtifact, which carried the JAR file — causing install:install to install the JAR instead of the POM. The fix removes the substitution: pomArtifact (built from ProjectArtifact) already wraps project.getFile() (the POM file), which is always the correct artifact to install. Regression test: src/it/minstall-315 runs jar:jar then install:install on a pom-packaged project and verifies that the installed artifact is XML (POM), not a JAR (ZIP).
gnodet-bot
left a comment
There was a problem hiding this comment.
The core fix is correct and well-reasoned. ProjectArtifact(project) calls setFile(project.getFile()) — always the POM file — so removing the pomArtifact = projectArtifact substitution is the right call: pomArtifact never needed to adopt the JAR file set by jar:jar. The equalsId branch is only entered for pom packaging (where G:A:V:E match), so non-pom projects are unaffected.
One nit on verify.groovy.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
gnodet-bot
left a comment
There was a problem hiding this comment.
The nit on verify.groovy has been addressed cleanly — the simplified version keeps only the ZIP magic-byte check (PK\u0003\u0004), which is both sufficient and unambiguous for catching the regression. The removed XML-detection block (fragile charset assumption, triple-nested if) was dead weight. Good call.
Core fix in InstallMojo.java is correct. ProjectArtifact(project) wraps project.getFile() — always the POM — so removing the pomArtifact = projectArtifact substitution is safe and minimal. Non-pom projects are unaffected since equalsId is only true when G:A:V:E match (pom packaging only).
Ready to merge.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
There doesn't seem to be an MINSTALL-315 issue. Please check and update. Tangential note, the consistent misuse of the old JIRA linking syntax to issues that don't exist or that are in github instead of Jira is some of the clearest evidence I've seen lately that the LLMs are cargo culting instead of actually thinking. |
Problem
When
jar:jaris invoked on apom-packaged project,maven-jar-plugin 3.xcallsproject.getArtifact().setFile(jarFile), setting the main artifact's file to the produced JAR.In
InstallMojo.processProject(), for apom-packaged project,pomArtifactandprojectArtifacthave the same coordinates. The existing code replacedpomArtifactwithprojectArtifactwhenprojectArtifacthad a file — which was the JAR set byjar:jar. This causedinstall:installto install the JAR under the.pomextension in the local repository.Root cause
In 3.1.1, this was guarded by
if (!"pom".equals(project.getPackaging())). That guard was removed in 3.1.2 (MINSTALL-192) with the intent of "handling it centrally" — but the central handling is the buggy substitution itself.Fix
Remove the
pomArtifact = projectArtifactsubstitution.pomArtifactis constructed vianew ProjectArtifact(project), which wrapsproject.getFile()— always the POM file, regardless of what other plugins set onproject.getArtifact().getFile(). This is the correct artifact to install.Test
Added IT
minstall-315: runsjar:jar install:installon apom-packaged project and verifies that the installed artifact is valid XML (a POM), not a ZIP (a JAR).Fixes MINSTALL-315