You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Jeremy Norris <je...@lbnetworks.co> on 2025/11/13 21:17:26 UTC
Consumer POM flattening behavior for profiles in Maven 4?
Hi,
What is the intended behavior of consumer POM flattening behavior in terms of profiles?
We have noticed in local testing that it can leave behind no-op profiles in a consumer POM instead of removing them entirely (as we would have anticipated).
For example, with a POM such as this:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<profiles>
<profile>
<id>lint</id>
<activation>
<jdk>[21,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-Xlint:all</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
```
We end up with a flattened consumer POM containing a no-op profile like this:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0.0-SNAPSHOT</version>
<profiles>
<profile>
<id>lint</id>
<activation>
<jdk>[21,)</jdk>
</activation>
</profile>
</profiles>
```
Is it intended to leave behind no-op profiles such as this in consumer POM’s when flattened?
Thanks,
Jeremy