{"record":{"id":"cd31a857ee60d4ea","repo":"apache/maven","slug":"the-consumer-pom-for-cannot-be-downgraded-to-4","errorCode":null,"errorMessage":"The consumer POM for {} cannot be downgraded to 4.0.0. If you intent your build to be consumed with Maven 3 projects, you need to remove the features that request a newer model version.  If you're fine with having the consumer POM not consumable with Maven 3, add the `preserve.model.version='true'` attribute on the <project> element of your POM.","messagePattern":"The consumer POM for (.+?) cannot be downgraded to 4\\.0\\.0\\. If you intent your build to be consumed with Maven 3 projects, you need to remove the features that request a newer model version\\.  If you're fine with having the consumer POM not consumable with Maven 3, add the `preserve\\.model\\.version='true'` attribute on the <project> element of your POM\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java","lineNumber":447,"sourceCode":"        if (!preserveModelVersion) {\n            /*\n             * If the <build> contains <source> elements, it is not compatible with the Maven 4.0.0 model.\n             * Remove the full <build> element instead of removing only the <sources> element, because the\n             * build without sources does not mean much. Reminder: this removal can be disabled by setting\n             * the `preserveModelVersion` XML attribute or `preserve.model.version` property to true.\n             */\n            if (SourceQueries.hasEnabledSources(projectSources)) {\n                model = model.withBuild(null);\n            }\n            model = model.withPreserveModelVersion(false);\n            String modelVersion = new MavenModelVersion().getModelVersion(model);\n            model = model.withModelVersion(modelVersion);\n        }\n        return model;\n    }\n\n    private static void warnNotDowngraded(MavenProject project) {\n        LOGGER.warn(\"The consumer POM for \" + project.getId() + \" cannot be downgraded to 4.0.0. \"\n                + \"If you intent your build to be consumed with Maven 3 projects, you need to remove \"\n                + \"the features that request a newer model version.  If you're fine with having the \"\n                + \"consumer POM not consumable with Maven 3, add the `preserve.model.version='true'` \"\n                + \"attribute on the <project> element of your POM.\");\n    }\n\n    private static List<Profile> prune(List<Profile> profiles) {\n        return profiles.stream()\n                .map(p -> {\n                    Profile.Builder builder = Profile.newBuilder(p, true);\n                    prune((ModelBase.Builder) builder, p);\n                    return builder.build(null).build();\n                })\n                .filter(p -> !isEmpty(p))\n                .collect(Collectors.toList());\n    }\n\n    private static boolean isEmpty(Profile profile) {","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java#L429-L465","documentation":"Maven 4 generates a consumer POM (the flattened POM that gets installed/deployed) downgraded to modelVersion 4.0.0 so Maven 3 consumers can read it. warnNotDowngraded fires when the project's model uses features that require a newer model version, making a 4.0.0 downgrade impossible: the consumer POM keeps the newer model version, and Maven 3 clients fail to parse it.","triggerScenarios":"A modelVersion 4.1+ project consumes newer model features (new scopes, consumer-POM-only constructs, etc.) so MavenModelVersion.getModelVersion returns something above 4.0.0, and preserve.model.version was not set to keep it deliberately.","commonSituations":"Maven 4 projects whose artifacts must also build as dependencies from Maven 3 builds (mixed toolchains in one organization); libraries published for wide consumption.","solutions":["If Maven 3 consumers must read your artifact: remove the features that require the newer model version (check what bumped the computed model version)","If Maven 3 compatibility is not required: add the attribute preserve.model.version='true' on the <project> element to acknowledge and silence the warning","Verify afterwards by opening the installed target's consumer POM and, if needed, consuming it from a Maven 3 build"],"exampleFix":"<!-- before -->\n<project xmlns=\"http://maven.apache.org/POM/4.1.0\">\n  <modelVersion>4.1.0</modelVersion>\n  ...\n</project>\n<!-- after (accept non-consumable consumer POM) -->\n<project xmlns=\"http://maven.apache.org/POM/4.1.0\" preserve.model.version=\"true\">\n  <modelVersion>4.1.0</modelVersion>\n  ...\n</project>","handlingStrategy":"validation","validationCode":"# CI guard: fail when a to-be-published POM needs a newer model than consumers support\nMODEL=$(mvn -q help:evaluate -Dexpression=project.modelVersion -DforceStdout)\nif [ \"$MODEL\" != \"4.0.0\" ] && ! grep -q 'preserve.model.version=\"true\"' pom.xml; then\n  echo \"consumer POM will not be Maven 3 consumable\"; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide consciously whether published artifacts must remain Maven 3 consumable","Set preserve.model.version='true' deliberately when staying on newer model features","Smoke-test published artifacts by consuming them from a Maven 3 build in CI"],"tags":["consumer-pom","model-version","maven-3-compat","maven-4"],"backgroundTag":"pom-model-version-compatibility","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}