{"record":{"id":"e808cc594111a135","repo":"apache/maven","slug":"the-consumer-pom-for-s-cannot-be-downgraded-to-mo","errorCode":null,"errorMessage":"The consumer POM for %s cannot be downgraded to model version 4.0.0 because it contains features that require a newer model version. Since consumer POM flattening is disabled, the parent reference is preserved, which requires consumers to resolve the parent POM.\nYou have the following options to resolve this:\n  1. Enable flattening by setting the property 'maven.consumer.pom.flatten=true' to inline parent content and produce a self-contained 4.0.0 consumer POM\n  2. Preserve the model version by setting 'preserve.model.version=true' on the <project> element (Maven 4 consumers only)\n  3. Remove the features that require a newer model version","messagePattern":"The consumer POM for %s cannot be downgraded to model version 4\\.0\\.0 because it contains features that require a newer model version\\. Since consumer POM flattening is disabled, the parent reference is preserved, which requires consumers to resolve the parent POM\\.\nYou have the following options to resolve this:\n  1\\. Enable flattening by setting the property 'maven\\.consumer\\.pom\\.flatten=true' to inline parent content and produce a self-contained 4\\.0\\.0 consumer POM\n  2\\. Preserve the model version by setting 'preserve\\.model\\.version=true' on the <project> element \\(Maven 4 consumers only\\)\n  3\\. Remove the features that require a newer model version","errorType":"exception","errorClass":"MavenException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java","lineNumber":161,"sourceCode":"            // When flattening is disabled, treat non-POM projects like parent POMs\n            // Apply only basic transformations without flattening dependency management\n            // BOMs always need the effective (interpolated) model because transformBom()\n            // strips parent and properties — any ${...} references would become dangling.\n            // The flatten flag has no semantic effect on BOMs (transformBom always produces\n            // a self-contained POM), so we use the same buildBom() path regardless.\n            if (isBom) {\n                return buildBom(session, project, src);\n            } else {\n                Model result = buildPom(session, project, src);\n                // Validate POM-packaged projects (parent POMs): if the consumer POM cannot be\n                // downgraded to 4.0.0, Maven 3 / Gradle cannot resolve the parent.\n                // Non-POM projects are consumed as dependencies where unknown elements are\n                // ignored, so a higher model version is acceptable (only a warning is logged\n                // by transformNonPom/transformPom).\n                if (POM_PACKAGING.equals(packaging)\n                        && !model.isPreserveModelVersion()\n                        && !ModelBuilder.MODEL_VERSION_4_0_0.equals(result.getModelVersion())) {\n                    throw new MavenException(\"\"\"\n                            The consumer POM for %s cannot be downgraded to model version 4.0.0 because it contains\\\n                             features that require a newer model version.\\\n                             Since consumer POM flattening is disabled, the parent reference is\\\n                             preserved, which requires consumers to resolve the parent POM.\n                            You have the following options to resolve this:\n                              1. Enable flattening by setting the property 'maven.consumer.pom.flatten=true'\\\n                             to inline parent content and produce a self-contained 4.0.0 consumer POM\n                              2. Preserve the model version by setting 'preserve.model.version=true'\\\n                             on the <project> element (Maven 4 consumers only)\n                              3. Remove the features that require a newer model version\"\"\".formatted(project.getId()));\n                }\n                return result;\n            }\n        }\n        // Default behavior: flatten the consumer POM\n        if (POM_PACKAGING.equals(packaging)) {\n            if (isBom) {\n                return buildBom(session, project, src);","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java#L143-L179","documentation":"After building a POM-packaged project's consumer POM, DefaultConsumerPomBuilder validates that the result could be downgraded to modelVersion 4.0.0. For packaging 'pom' the artifact IS the parent that Maven 3/Gradle consumers must resolve, so if it still needs a newer model version (and the parent reference is preserved because flattening is off), the build fails: old consumers would not be able to read it.","triggerScenarios":"A <packaging>pom</packaging> project using 4.1+ model features (mixins, subprojects, new dependency attributes...) where the transformed consumer POM's modelVersion is not 4.0.0, while both 'maven.consumer.pom.flatten' and 'preserve.model.version' are disabled. The check at buildPom's call site throws MavenException listing three remediation options.","commonSituations":"Publishing a Maven 4 parent/BOM with new syntax that Maven 3 users consume; enabling consumer POM generation but forgetting flattening for parent-POM projects; mixing 4.x-only features into a parent inherited by 3.x builds.","solutions":["Enable flattening: set 'maven.consumer.pom.flatten=true' so parent content is inlined into a self-contained 4.0.0 consumer POM","Or set 'preserve.model.version=true' on <project> if all consumers are Maven 4","Or remove the 4.1+ features from the parent POM so it downgrades cleanly to 4.0.0","If Maven 3 compatibility is required, keep the parent strictly 4.0.0-compatible (flattening on is the usual choice)"],"exampleFix":"# before\nmvn deploy   # parent POM with 4.1 features, no flatten -> MavenException\n\n# after (in the parent pom.xml properties or .mvn/maven.config)\nmaven.consumer.pom.flatten=true\nmvn deploy","handlingStrategy":"validation","validationCode":"// for packaging=pom projects, guard before deploy\nif (\"pom\".equals(model.getPackaging()) && !flattenEnabled && !model.isPreserveModelVersion()) {\n    // ensure the transformed model downgrades to 4.0.0, otherwise fail early with guidance\n}","typeGuard":null,"tryCatchPattern":"catch (MavenException e) {\n    if (e.getMessage().contains(\"cannot be downgraded\")) {\n        // enable flatten / preserve model version / remove 4.1 features, then rebuild\n    }\n}","preventionTips":["Publish parent POMs from a Maven version/feature set compatible with your consumers","Enable flattening for all parent/bom modules in the CI release profile","Smoke-test published parent POMs by building a sample Maven 3 project against them"],"tags":["maven","consumer-pom","model-version","parent-pom","compatibility"],"backgroundTag":"consumer-pom-feature-unsupported","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}