Skip to content

Support Maven version range activation for profiles #11694

@hazendaz

Description

@hazendaz

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:

  1. Automatically activates profiles for any future Maven 4.x releases.
  2. Eliminates the need for multiple exact-match profiles.
  3. Simplifies plugin version overrides for Maven 4.
  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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions