如何升级maven插件的版本?

时间:2022-06-08 14:54:58

I am using the maven-ear-plugin version 2.3.1 - I know there is a new version available: http://maven.apache.org/plugins/maven-ear-plugin/

我正在使用maven-ear-plugin版本2.3.1 - 我知道有一个新版本可用:http://maven.apache.org/plugins/maven-ear-plugin/

I can't work out how to upgrade to the latest version?

我无法弄清楚如何升级到最新版本?

4 个解决方案

#1


The default plugin versions are inherited from the Super POM, and you can check them with mvn help:effective-pom.

默认插件版本继承自Super POM,您可以使用mvn help:effective-pom进行检查。

If you want to override the version provided there, add this to your POM:

如果要覆盖此处提供的版本,请将其添加到POM:

<project>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.3.1</version>
      </plugin>
    </plugins>
  </build>
</project>

Replace the version with what you need.

用您需要的版本替换版本。

#2


Even though this has already gotten the "approved answer", it turns out that there is this AWESOME versions plugin that handles the neverending version maintenance problem.

虽然这已经得到了“批准的答案”,但事实证明,有一个AWESOME版本插件可以处理无休止的版本维护问题。

For those lazy people here are some of its goals:

对于那些懒惰的人来说,这里有一些目标:

  • versions:display-dependency-updates scans a project's dependencies and produces a report of those dependencies which have newer versions available.
  • versions:display-dependency-updates扫描项目的依赖项,并生成具有更新版本的依赖项的报告。

  • versions:display-plugin-updates scans a project's plugins and produces a report of those plugins which have newer versions available.
  • 版本:display-plugin-updates扫描项目的插件,并生成那些具有更新版本的插件的报告。

  • versions:display-property-updates scans a projectand produces a report of those properties which are used to control artifact versions and which properies have newer versions available.
  • versions:display-property-updates扫描项目并生成用于控制工件版本的属性的报告,以及哪些属性具有可用的新版本。

  • versions:update-parent updates the parent section of a project so that it references the newest available version. For example, if you use a corporate root POM, this goal can be helpful if you need to ensure you are using the latest version of the corporate root POM.
  • versions:update-parent更新项目的父节点,以便它引用最新的可用版本。例如,如果您使用公司根POM,如果您需要确保使用最新版本的公司根POM,则此目标会很有用。

  • versions:update-properties updates properties defined in a project so that they correspond to the latest available version of specific dependencies. This can be useful if a suite of dependencies must all be locked to one version.
  • versions:update-properties更新项目中定义的属性,以便它们对应于特定依赖项的最新可用版本。如果必须将一组依赖项全部锁定到一个版本,这将非常有用。

  • versions:update-child-modules updates the parent section of the child modules of a project so the version matches the version of the current project. For example, if you have an aggregator pom that is also the parent for the projects that it aggregates and the children and parent versions get out of sync, this mojo can help fix the versions of the child modules. (Note you may need to invoke Maven with the -N option in order to run this goal if your project is broken so badly that it cannot build because of the version mis-match).
  • versions:update-child-modules更新项目子模块的父节点,以使版本与当前项目的版本匹配。例如,如果您有一个聚合器pom,它也是它聚合的项目的父级,并且子级和父级版本不同步,则此mojo可以帮助修复子模块的版本。 (注意,如果您的项目因为版本不匹配而无法构建,那么您可能需要使用-N选项调用Maven以运行此目标。

  • versions:lock-snapshots searches the pom for all -SNAPSHOT versions and replaces them with the current timestamp version of that -SNAPSHOT, e.g. -20090327.172306-4
  • 版本:lock-snapshots在pom中搜索所有-SNAPSHOT版本,并用该-SNAPSHOT的当前时间戳版本替换它们,例如: -20090327.172306-4

  • versions:unlock-snapshots searches the pom for all timestamp locked snapshot versions and replaces them with -SNAPSHOT.
  • 版本:unlock-snapshots在pom中搜索所有时间戳锁定的快照版本,并用-SNAPSHOT替换它们。

  • versions:set can be used to set the project version from the command line.
  • versions:set可用于从命令行设置项目版本。

  • versions:use-releases searches the pom for all -SNAPSHOT versions which have been released and replaces them with the corresponding release version.
  • 版本:use-releases在pom中搜索已发布的所有-SNAPSHOT版本,并将其替换为相应的发行版本。

  • versions:use-next-releases searches the pom for all non-SNAPSHOT versions which have been a newer release and replaces them with the next release version.
  • 版本:use-next-releases在pom中搜索所有非SNAPSHOT版本,这些版本是较新的版本,并将其替换为下一个版本。

  • versions:use-latest-releases searches the pom for all non-SNAPSHOT versions which have been a newer release and replaces them with the latest release version.
  • 版本:use-latest-releases在pom中搜索所有非SNAPSHOT版本,这些版本是较新版本,并将其替换为最新版本。

  • versions:use-next-snapshots searches the pom for all non-SNAPSHOT versions which have been a newer -SNAPSHOT version and replaces them with the next -SNAPSHOT version.
  • 版本:use-next-snapshots在pom中搜索所有非SNAPSHOT版本,这些版本是较新的-SNAPSHOT版本,并将其替换为下一个-SNAPSHOT版本。

  • versions:use-latest-snapshots searches the pom for all non-SNAPSHOT versions which have been a newer -SNAPSHOT version and replaces them with the latest -SNAPSHOT version.
  • 版本:use-latest-snapshots在pom中搜索所有非SNAPSHOT版本,这些版本是较新的-SNAPSHOT版本,并用最新的-SNAPSHOT版本替换它们。

  • versions:use-next-versions searches the pom for all versions which have been a newer version and replaces them with the next version.
  • 版本:use-next-versions在pom中搜索所有版本较新的版本,并将其替换为下一版本。

  • versions:use-latest-versions searches the pom for all versions which have been a newer version and replaces them with the latest version.
  • 版本:use-latest-versions在pom中搜索所有版本较新的版本,并用最新版本替换它们。

#3


How the version of a plugin is selected, along with discussion about the plugin versions in the superpom is covered in detail here.

这里将详细介绍如何选择插件的版本,以及有关superpom中插件版本的讨论。

Actually the currently selected answer isn't quite right. It should be

实际上当前选择的答案并不完全正确。它应该是

<project>
  <build>
   <pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.3.1</version>
      </plugin>
    </plugins>
   </pluginManagement>
  </build>
</project>

I explained why here:

我在这里解释了原因:

"The regular plugins section also allows the version and default configuration to be defined, and this is where the confusion lies. It is technically valid to define the plugin version and default configuration here, but I find it easier to grok the pom when following this guideline:

“常规插件部分还允许定义版本和默认配置,这就是混乱的地方。在这里定义插件版本和默认配置在技术上是有效的,但我发现在关注这个时更容易理解pom指南:

If the plugin block is not defining an execution (and thus binding maven to do something in the lifecycle), put that block in pluginManagment"

如果插件块没有定义执行(因此绑定maven在生命周期中执行某些操作),请将该块放在pluginManagment中“

#4


Some maven plugins are restricted to maven versions. For example, generally projects around here use Maven 2.0.4, which is restricted to use the war plugin 2.0.2 - this works with overlays. The 2.1-alpha whatever, however, that Maven 2.0.9 uses, does not - so we had to manually downgrade. Maven, unless otherwise instructed, will attempt to use the latest version of a plugin that it can according to its version.

一些maven插件仅限于maven版本。例如,通常这里的项目使用Maven 2.0.4,仅限于使用war插件2.0.2 - 这适用于叠加。然而,无论Maven 2.0.9使用哪种2.1-alpha都没有 - 所以我们不得不手动降级。除非另有说明,Maven将尝试根据其版本使用最新版本的插件。

#1


The default plugin versions are inherited from the Super POM, and you can check them with mvn help:effective-pom.

默认插件版本继承自Super POM,您可以使用mvn help:effective-pom进行检查。

If you want to override the version provided there, add this to your POM:

如果要覆盖此处提供的版本,请将其添加到POM:

<project>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.3.1</version>
      </plugin>
    </plugins>
  </build>
</project>

Replace the version with what you need.

用您需要的版本替换版本。

#2


Even though this has already gotten the "approved answer", it turns out that there is this AWESOME versions plugin that handles the neverending version maintenance problem.

虽然这已经得到了“批准的答案”,但事实证明,有一个AWESOME版本插件可以处理无休止的版本维护问题。

For those lazy people here are some of its goals:

对于那些懒惰的人来说,这里有一些目标:

  • versions:display-dependency-updates scans a project's dependencies and produces a report of those dependencies which have newer versions available.
  • versions:display-dependency-updates扫描项目的依赖项,并生成具有更新版本的依赖项的报告。

  • versions:display-plugin-updates scans a project's plugins and produces a report of those plugins which have newer versions available.
  • 版本:display-plugin-updates扫描项目的插件,并生成那些具有更新版本的插件的报告。

  • versions:display-property-updates scans a projectand produces a report of those properties which are used to control artifact versions and which properies have newer versions available.
  • versions:display-property-updates扫描项目并生成用于控制工件版本的属性的报告,以及哪些属性具有可用的新版本。

  • versions:update-parent updates the parent section of a project so that it references the newest available version. For example, if you use a corporate root POM, this goal can be helpful if you need to ensure you are using the latest version of the corporate root POM.
  • versions:update-parent更新项目的父节点,以便它引用最新的可用版本。例如,如果您使用公司根POM,如果您需要确保使用最新版本的公司根POM,则此目标会很有用。

  • versions:update-properties updates properties defined in a project so that they correspond to the latest available version of specific dependencies. This can be useful if a suite of dependencies must all be locked to one version.
  • versions:update-properties更新项目中定义的属性,以便它们对应于特定依赖项的最新可用版本。如果必须将一组依赖项全部锁定到一个版本,这将非常有用。

  • versions:update-child-modules updates the parent section of the child modules of a project so the version matches the version of the current project. For example, if you have an aggregator pom that is also the parent for the projects that it aggregates and the children and parent versions get out of sync, this mojo can help fix the versions of the child modules. (Note you may need to invoke Maven with the -N option in order to run this goal if your project is broken so badly that it cannot build because of the version mis-match).
  • versions:update-child-modules更新项目子模块的父节点,以使版本与当前项目的版本匹配。例如,如果您有一个聚合器pom,它也是它聚合的项目的父级,并且子级和父级版本不同步,则此mojo可以帮助修复子模块的版本。 (注意,如果您的项目因为版本不匹配而无法构建,那么您可能需要使用-N选项调用Maven以运行此目标。

  • versions:lock-snapshots searches the pom for all -SNAPSHOT versions and replaces them with the current timestamp version of that -SNAPSHOT, e.g. -20090327.172306-4
  • 版本:lock-snapshots在pom中搜索所有-SNAPSHOT版本,并用该-SNAPSHOT的当前时间戳版本替换它们,例如: -20090327.172306-4

  • versions:unlock-snapshots searches the pom for all timestamp locked snapshot versions and replaces them with -SNAPSHOT.
  • 版本:unlock-snapshots在pom中搜索所有时间戳锁定的快照版本,并用-SNAPSHOT替换它们。

  • versions:set can be used to set the project version from the command line.
  • versions:set可用于从命令行设置项目版本。

  • versions:use-releases searches the pom for all -SNAPSHOT versions which have been released and replaces them with the corresponding release version.
  • 版本:use-releases在pom中搜索已发布的所有-SNAPSHOT版本,并将其替换为相应的发行版本。

  • versions:use-next-releases searches the pom for all non-SNAPSHOT versions which have been a newer release and replaces them with the next release version.
  • 版本:use-next-releases在pom中搜索所有非SNAPSHOT版本,这些版本是较新的版本,并将其替换为下一个版本。

  • versions:use-latest-releases searches the pom for all non-SNAPSHOT versions which have been a newer release and replaces them with the latest release version.
  • 版本:use-latest-releases在pom中搜索所有非SNAPSHOT版本,这些版本是较新版本,并将其替换为最新版本。

  • versions:use-next-snapshots searches the pom for all non-SNAPSHOT versions which have been a newer -SNAPSHOT version and replaces them with the next -SNAPSHOT version.
  • 版本:use-next-snapshots在pom中搜索所有非SNAPSHOT版本,这些版本是较新的-SNAPSHOT版本,并将其替换为下一个-SNAPSHOT版本。

  • versions:use-latest-snapshots searches the pom for all non-SNAPSHOT versions which have been a newer -SNAPSHOT version and replaces them with the latest -SNAPSHOT version.
  • 版本:use-latest-snapshots在pom中搜索所有非SNAPSHOT版本,这些版本是较新的-SNAPSHOT版本,并用最新的-SNAPSHOT版本替换它们。

  • versions:use-next-versions searches the pom for all versions which have been a newer version and replaces them with the next version.
  • 版本:use-next-versions在pom中搜索所有版本较新的版本,并将其替换为下一版本。

  • versions:use-latest-versions searches the pom for all versions which have been a newer version and replaces them with the latest version.
  • 版本:use-latest-versions在pom中搜索所有版本较新的版本,并用最新版本替换它们。

#3


How the version of a plugin is selected, along with discussion about the plugin versions in the superpom is covered in detail here.

这里将详细介绍如何选择插件的版本,以及有关superpom中插件版本的讨论。

Actually the currently selected answer isn't quite right. It should be

实际上当前选择的答案并不完全正确。它应该是

<project>
  <build>
   <pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.3.1</version>
      </plugin>
    </plugins>
   </pluginManagement>
  </build>
</project>

I explained why here:

我在这里解释了原因:

"The regular plugins section also allows the version and default configuration to be defined, and this is where the confusion lies. It is technically valid to define the plugin version and default configuration here, but I find it easier to grok the pom when following this guideline:

“常规插件部分还允许定义版本和默认配置,这就是混乱的地方。在这里定义插件版本和默认配置在技术上是有效的,但我发现在关注这个时更容易理解pom指南:

If the plugin block is not defining an execution (and thus binding maven to do something in the lifecycle), put that block in pluginManagment"

如果插件块没有定义执行(因此绑定maven在生命周期中执行某些操作),请将该块放在pluginManagment中“

#4


Some maven plugins are restricted to maven versions. For example, generally projects around here use Maven 2.0.4, which is restricted to use the war plugin 2.0.2 - this works with overlays. The 2.1-alpha whatever, however, that Maven 2.0.9 uses, does not - so we had to manually downgrade. Maven, unless otherwise instructed, will attempt to use the latest version of a plugin that it can according to its version.

一些maven插件仅限于maven版本。例如,通常这里的项目使用Maven 2.0.4,仅限于使用war插件2.0.2 - 这适用于叠加。然而,无论Maven 2.0.9使用哪种2.1-alpha都没有 - 所以我们不得不手动降级。除非另有说明,Maven将尝试根据其版本使用最新版本的插件。