Search code examples
mavenversionversions-maven-plugin

When writing a maven plugin how to specify the allowed maven version


mvn versions:display-plugin-updates

displays a line

Plugins require minimum Maven version of: 3.9.1

I write a plugin and I want to provide also version of maven it works with so that it shows up in versions plugin. How can I do this???


Solution

  • Please use prerequisites in your plugin project.

    It is also good practice to use the same version of Maven Plugin Api and other Maven core artifacts.

    So project can look like:

    <project>
    
    ...
    
      <packaging>maven-plugin</packaging>
    
    ...
    
      <prerequisites>
        <maven>${mavenVersion}</maven>
      </prerequisites>
    
      <properties>
        <mavenVersion>minimum-supported-version</mavenVersion>
      </properties>
    
      <dependencies>
        <dependency>
          <groupId>org.apache.maven</groupId>
          <artifactId>maven-plugin-api</artifactId>
          <version>${mavenVersion}</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.maven</groupId>
          <artifactId>maven-core</artifactId>
          <version>${mavenVersion}</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
    
    ...
    
    </project>