编写maven插件时如何指定允许的maven版本

问题描述 投票:0回答:1
mvn versions:display-plugin-updates

显示一条线

Plugins require minimum Maven version of: 3.9.1

我写了一个插件,我想提供它适用的 Maven 版本 以便它显示在版本插件中。 我怎样才能做到这一点???

maven version versions-maven-plugin
1个回答
0
投票

请在您的插件项目中使用

prerequisites

使用相同版本的 Maven Plugin Api 和其他 Maven 核心工件也是一个很好的做法。

所以项目可以是这样的:

<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>

© www.soinside.com 2019 - 2024. All rights reserved.