How do I upgrade the version of a maven plugin?

后端 未结 4 1152
旧时难觅i
旧时难觅i 2021-01-30 11:10

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/

I can\'t work out how to upgra

相关标签:
4条回答
  • 2021-01-30 11:38

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

    If you want to override the version provided there, add this to your 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.

    0 讨论(0)
  • 2021-01-30 11:41

    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.

    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-plugin-updates scans a project's plugins and produces a report of those plugins which have newer versions available.
    • 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: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-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-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: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
    • versions:unlock-snapshots searches the pom for all timestamp locked snapshot versions and replaces them with -SNAPSHOT.
    • versions:set can be used to set the project version from the command line.
    • versions:use-releases searches the pom for all -SNAPSHOT versions which have been released and replaces them with the corresponding release version.
    • 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.
    • 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.
    • 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.
    • 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.
    • versions:use-next-versions searches the pom for all versions which have been a newer version and replaces them with the next version.
    • versions:use-latest-versions searches the pom for all versions which have been a newer version and replaces them with the latest version.
    0 讨论(0)
  • 2021-01-30 11:43

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

    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:

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

    0 讨论(0)
  • 2021-01-30 11:48

    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.

    0 讨论(0)
提交回复
热议问题