fix: use Maven 4 consumer POM instead of build POM#51
fix: use Maven 4 consumer POM instead of build POM#51mhoffrog merged 1 commit intomavenplugins:masterfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughAdds Maven 4 consumer POM detection and preference in ProjectUtilsImpl: consumer POMs are used as the primary POM when present, filtered from attached-artifact lists, and consumer-POM signatures substitute build-POM signatures. A new test class and Mockito inline config validate the behavior. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/test/java/org/sonatype/central/publisher/plugin/utils/ProjectUtilsImplConsumerPomTest.java (1)
84-115: Add a test for the attached-only fallback branch.Current tests don’t exercise the
file == null && !attachedArtifacts.isEmpty()path inProjectUtilsImpl, where POM file selection can regress independently.Also applies to: 121-137
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/org/sonatype/central/publisher/plugin/utils/ProjectUtilsImplConsumerPomTest.java` around lines 84 - 115, Add a new test (or extend shouldNotIncludeConsumerPomAsSeparateArtifact) to exercise the attached-only fallback branch in ProjectUtilsImpl.getArtifacts by creating a MavenProject whose main Artifact has file == null but attachedArtifacts is non-empty (include a consumer POM with classifier "consumer" and another attached artifact like sources), then call projectUtils.getArtifacts(project, artifactFactory) and assert the consumer POM is not returned as a separate ArtifactWithFile and only the expected artifacts (e.g., sources and main jar replacement behavior) are present; this targets the code path where file == null && !attachedArtifacts.isEmpty() so POM selection doesn't regress.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/main/java/org/sonatype/central/publisher/plugin/utils/ProjectUtilsImpl.java`:
- Around line 161-163: The fallback branch is using mavenProject.getFile() and
bypasses the consumer-POM selected by findConsumerPom; capture the result of
findConsumerPom(mavenProject) into a pomFile variable and ensure that
artifact.addMetadata(new ProjectArtifactMetadata(...)) and the attached-only
fallback both use that same pomFile (instead of calling mavenProject.getFile()
directly) so the consumer-aware POM is always used (refer to findConsumerPom,
mavenProject, artifact.addMetadata, and ProjectArtifactMetadata to locate the
affected logic).
In
`@src/test/java/org/sonatype/central/publisher/plugin/utils/ProjectUtilsImplConsumerPomTest.java`:
- Around line 81-82: Update the Javadoc comment in the
ProjectUtilsImplConsumerPomTest class: remove the stale phrase "Currently FAILS
- " from the comment that says "Currently FAILS - consumer POM leaks into the
artifact list." (or reword the whole sentence) so the test class comment
reflects the fixed state; locate the comment block in
ProjectUtilsImplConsumerPomTest and edit the Javadoc to a neutral or accurate
description of the test purpose.
---
Nitpick comments:
In
`@src/test/java/org/sonatype/central/publisher/plugin/utils/ProjectUtilsImplConsumerPomTest.java`:
- Around line 84-115: Add a new test (or extend
shouldNotIncludeConsumerPomAsSeparateArtifact) to exercise the attached-only
fallback branch in ProjectUtilsImpl.getArtifacts by creating a MavenProject
whose main Artifact has file == null but attachedArtifacts is non-empty (include
a consumer POM with classifier "consumer" and another attached artifact like
sources), then call projectUtils.getArtifacts(project, artifactFactory) and
assert the consumer POM is not returned as a separate ArtifactWithFile and only
the expected artifacts (e.g., sources and main jar replacement behavior) are
present; this targets the code path where file == null &&
!attachedArtifacts.isEmpty() so POM selection doesn't regress.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cd603dae-7249-4af9-82ee-75a85d45dc61
📒 Files selected for processing (3)
src/main/java/org/sonatype/central/publisher/plugin/utils/ProjectUtilsImpl.javasrc/test/java/org/sonatype/central/publisher/plugin/utils/ProjectUtilsImplConsumerPomTest.javasrc/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
592a31d to
30da9e0
Compare
Maven 4 generates a consumer POM (classifier="consumer", type="pom")
that contains resolved versions and model 4.0.0 - this is what should
be deployed to Maven Central. Previously the plugin always used the
build POM (mavenProject.getFile()) which contains unresolved
${revision} and model 4.1.0, causing Central Portal to reject the
deployment with "Failed to associate file with coordinates".
The fix:
- Detect consumer POM among attached artifacts
- Use it as ProjectArtifactMetadata instead of build POM
- Filter consumer POM artifacts from attached artifacts list
- Swap build POM GPG signature with consumer POM signature
Backwards compatible - without consumer POM (Maven 3) behavior
is unchanged.
30da9e0 to
18e13eb
Compare
|
@mariuszs Many THANKS for your contribution! 👍 |
Summary
consumer, typepom) containing resolved versions and model 4.0.0mavenProject.getFile()(the build POM) which contains unresolved${revision}and model 4.1.0The fix
In
ProjectUtilsImpl:ProjectArtifactMetadatainstead of the build POM-consumer.pomfile in the bundleBackwards compatible — without consumer POM (Maven 3 projects) behavior is unchanged.
Test plan
shouldNotIncludeConsumerPomAsSeparateArtifact— verifies consumer POM is used as main POM metadata and filtered from artifactsshouldWorkNormallyWithoutConsumerPom— verifies Maven 3 backwards compatibilityRelated
Summary by CodeRabbit
Bug Fixes
Tests