apache/maven · error · MavenException
The consumer POM for {} cannot be created because the POM co
Error message
The consumer POM for {} cannot be created because the POM contains mixins. Mixins are not supported in the default consumer POM format. You have the following options to resolve this:
1. Preserve the model version by setting 'preserve.model.version=true' to generate a consumer POM with <modelVersion>4.2.0</modelVersion>, which supports mixins
2. Enable flattening by setting the property 'maven.consumer.pom.flatten=true' to remove mixins during transformation
3. Remove the mixins from your POM What it means
DefaultConsumerPomBuilder refuses to generate the default 4.0.0 consumer POM when the model uses <mixins>: mixins are a 4.1+ model feature that the 4.0.0 consumer format cannot represent. The build() method only proceeds when flattening (maven.consumer.pom.flatten=true, which inlines/removes mixins) is enabled or the model version is preserved (preserve.model.version=true, keeping a 4.2.0 consumer POM).
Source
Thrown at impl/maven-core/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java:129
@SuppressWarnings("checkstyle:ParameterNumber")
DefaultConsumerPomBuilder(LifecycleBindingsInjector lifecycleBindingsInjector) {
this.lifecycleBindingsInjector = lifecycleBindingsInjector;
}
@Override
public Model build(RepositorySystemSession session, MavenProject project, ModelSource src)
throws ModelBuilderException {
Model model = project.getModel().getDelegate();
boolean flattenEnabled = Features.consumerPomFlatten(session.getConfigProperties());
String packaging = model.getPackaging();
String originalPackaging = project.getOriginalModel().getPackaging();
// Check if this is a BOM (original packaging is "bom")
boolean isBom = BOM_PACKAGING.equals(originalPackaging);
// Check if mixins are present without flattening enabled
if (!model.getMixins().isEmpty() && !flattenEnabled && !model.isPreserveModelVersion()) {
throw new MavenException("The consumer POM for "
+ project.getId()
+ " cannot be created because the POM contains mixins. "
+ "Mixins are not supported in the default consumer POM format. "
+ "You have the following options to resolve this:" + System.lineSeparator()
+ " 1. Preserve the model version by setting 'preserve.model.version=true' to generate a consumer POM with <modelVersion>4.2.0</modelVersion>, which supports mixins"
+ System.lineSeparator()
+ " 2. Enable flattening by setting the property 'maven.consumer.pom.flatten=true' to remove mixins during transformation"
+ System.lineSeparator()
+ " 3. Remove the mixins from your POM");
}
// Check if consumer POM flattening is disabled
if (!flattenEnabled) {
// When flattening is disabled, treat non-POM projects like parent POMs
// Apply only basic transformations without flattening dependency management
// BOMs always need the effective (interpolated) model because transformBom()
// strips parent and properties — any ${...} references would become dangling.
// The flatten flag has no semantic effect on BOMs (transformBom always producesView on GitHub (pinned to e4093d4e12)
Solutions
- Set 'maven.consumer.pom.flatten=true' (e.g. in .mvn/maven.config or the POM properties) so mixins are flattened away during transformation
- Or set 'preserve.model.version=true' to emit a 4.2.0 consumer POM that still supports mixins (Maven 4 consumers only)
- Or remove the <mixins> element and inline its content manually
- Verify the property actually reaches the session — it must be resolvable at deploy time, not only locally
Example fix
<!-- before --> <project> <mixins><mixin>org.acme:shared-config:1.0</mixin></mixins> <!-- no properties: build fails with this error on install/deploy --> <!-- after --> <properties> <maven.consumer.pom.flatten>true</maven.consumer.pom.flatten> </properties>
Defensive patterns
Strategy: validation
Validate before calling
// before install/deploy
boolean hasMixins = !model.getMixins().isEmpty();
boolean flatten = "true".equals(System.getProperty("maven.consumer.pom.flatten", props.get("maven.consumer.pom.flatten")));
if (hasMixins && !flatten && !model.isPreserveModelVersion()) {
throw new IllegalStateException("Configure maven.consumer.pom.flatten=true before deploying");
} Try / catch
catch (MavenException e) {
if (e.getMessage().contains("contains mixins")) {
// apply option 1/2/3 from the message, then retry the deploy
}
} Prevention
- Whenever you introduce <mixins>, set maven.consumer.pom.flatten=true in the same commit
- Test 'mvn deploy' in a dry environment (local repo) before releasing
- Keep consumer-facing POM features documented in the project README
When it happens
Trigger: Running install/deploy on a project whose POM declares <mixins>, with both 'maven.consumer.pom.flatten' unset/false and 'preserve.model.version' unset/false. The consumer POM builder then cannot downgrade to 4.0.0 and throws MavenException before writing the attached artifact.
Common situations: Adopting Maven 4 mixins for POM composition and then running a stock 'mvn deploy' without the companion properties; CI pipelines that flatten was forgotten to be configured; building a 4.x project with older tooling assumptions where mixins were silently ignored.
Related errors
- The consumer POM for %s cannot be downgraded to model versio
- Error installing metadata: {}
- Error while deploying metadata: {}
- The use of the root attribute on the model requires the buil
- Duplicate dependency: {}
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/1997a1cb74bcb9af.
Report an issue: GitHub.