Skip to content

Commit de91c68

Browse files
gnodetclaude
andcommitted
[GH-11772] Fix remaining CI failures: scope validation to POM packaging only
- Restrict consumer POM model version validation to POM-packaged projects only. Non-POM projects (jar, war, etc.) are consumed as dependencies where Maven 3 ignores unknown elements, so a higher model version is acceptable. - Restore original expected error message in MavenITgh11456 mixin test to match the restored mixin-specific check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e445b49 commit de91c68

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,13 @@ public Model build(RepositorySystemSession session, MavenProject project, ModelS
145145
return buildBomWithoutFlatten(session, project, src);
146146
} else {
147147
Model result = buildPom(session, project, src);
148-
// Validate: if flattening is disabled and the consumer POM cannot be downgraded
149-
// to 4.0.0, the consumer POM will contain features that Maven 3 / Gradle cannot
150-
// understand. Reject the build with actionable guidance.
151-
if (!model.isPreserveModelVersion()
148+
// Validate POM-packaged projects (parent POMs): if the consumer POM cannot be
149+
// downgraded to 4.0.0, Maven 3 / Gradle cannot resolve the parent.
150+
// Non-POM projects are consumed as dependencies where unknown elements are
151+
// ignored, so a higher model version is acceptable (only a warning is logged
152+
// by transformNonPom/transformPom).
153+
if (POM_PACKAGING.equals(packaging)
154+
&& !model.isPreserveModelVersion()
152155
&& !ModelBuilder.MODEL_VERSION_4_0_0.equals(result.getModelVersion())) {
153156
throw new MavenException("The consumer POM for " + project.getId()
154157
+ " cannot be downgraded to model version 4.0.0 because it contains"

its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh11456MixinsConsumerPomTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void testMixinsWithoutFlattening() throws Exception {
5252
// Expected to fail due to mixins without flattening
5353
}
5454

55-
verifier.verifyTextInLog("cannot be downgraded to model version 4.0.0");
55+
verifier.verifyTextInLog("cannot be created because the POM contains mixins");
5656
verifier.verifyTextInLog("maven.consumer.pom.flatten=true");
5757
}
5858

0 commit comments

Comments
 (0)