New feature, improvement proposal
Currently, Maven allows profile activation based on the JDK version using the <jdk> element, which supports version ranges:
<activation>
<jdk>[17,)</jdk>
</activation>
This works reliably for activating profiles for any compatible JDK, including future minor versions.
However, there is no equivalent mechanism for Maven versions.
The current workaround using
<activation>
<property>
<name>maven.version</name>
<value>…</value>
</property>
</activation>
only supports exact string matches.
For example:
<activation>
<property>
<name>maven.version</name>
<value>4.0.0-rc-5</value>
</property>
</activation>
This approach is fragile and unmaintainable:
Each new Maven 4 release requires adding a new profile or updating the existing one.
Automatic activation for a range of Maven 4 versions is not possible.
It complicates plugin property overrides and build automation.
Proposed improvement:
Introduce a new activation element that behaves like and supports version ranges. Example usage:
<profile>
<id>maven4</id>
<activation>
<maven>[4,)</maven>
</activation>
<properties>
<!-- overrides for Maven 4 -->
<clean.plugin>4.0.0-beta-2</clean.plugin>
<compiler.plugin>4.0.0-beta-4</compiler.plugin>
<deploy.plugin>4.0.0-beta-2</deploy.plugin>
<install.plugin>4.0.0-beta-2</install.plugin>
</properties>
</profile>
Benefits:
- Automatically activates profiles for any future Maven 4.x releases.
- Eliminates the need for multiple exact-match profiles.
- Simplifies plugin version overrides for Maven 4.
- Keeps builds future-proof and reduces maintenance overhead.
This would bring feature parity between JDK and Maven version activation and is fully backward-compatible for Maven 3 and existing builds.
New feature, improvement proposal
Currently, Maven allows profile activation based on the JDK version using the
<jdk>element, which supports version ranges:This works reliably for activating profiles for any compatible JDK, including future minor versions.
However, there is no equivalent mechanism for Maven versions.
The current workaround using
only supports exact string matches.
For example:
This approach is fragile and unmaintainable:
Each new Maven 4 release requires adding a new profile or updating the existing one.
Automatic activation for a range of Maven 4 versions is not possible.
It complicates plugin property overrides and build automation.
Proposed improvement:
Introduce a new activation element that behaves like and supports version ranges. Example usage:
Benefits:
This would bring feature parity between JDK and Maven version activation and is fully backward-compatible for Maven 3 and existing builds.