java 如何显示插件版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5724359/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 12:29:27  来源:igfitidea点击:

How to show plugin versions

javamaven

提问by user705414

I want to know the version of plugin installed. Which command can do it?

我想知道安装的插件版本。哪个命令可以做到?

回答by twister_void

mvn -Dplugin=<groupId>:<artifactId> help:describe

detailed description of the plugin - including the version

插件的详细描述 - 包括版本

回答by Conny Krey?el

If you would to know which version of plugins (incl. plugins provided through maven master pom) your build use, try:

如果您想知道您的构建使用哪个版本的插件(包括通过 maven master pom 提供的插件),请尝试:

mvn help:effective-pom

回答by FrVaBe

I don't know what you mean by 'version of plugin installed' but the Maven help pluginenables you to get the desciption of a plugin by giving the groupId and artifactId,

我不知道您所说的“已安装插件的版本”是什么意思,但是Maven 帮助插件使您能够通过提供 groupId 和 artifactId 来获取插件的描述,

mvn -Dplugin=<groupId>:<artifactId> help:describe

You will get a detailed description of the plugin - including the version (although I must admit that I don't know the strategy of version number resolving).

你会得到插件的详细描述——包括版本(虽然我必须承认我不知道版本号解析的策略)。

Examplefor the maven-dependency-plugin

maven-dependency-plugin 的示例

mvn -Dplugin=org.apache.maven.plugins:maven-dependency-plugin help:describe

Output:

输出

Name: Maven Dependency Plugin
Description: Provides utility goals to work with dependencies like copying,
  unpacking, analyzing, resolving and many more.
Group Id: org.apache.maven.plugins
Artifact Id: maven-dependency-plugin
Version: 2.2
Goal Prefix: dependency

This plugin has 21 goals:

dependency:analyze
  Description: Analyzes the dependencies of this project and determines which
    are: used and declared; used and undeclared; unused and declared. This goal
    is intended to be used standalone, thus it always executes the test-compile
    phase - use the dependency:analyze-only goal instead when participating in
    the build lifecycle.

dependency:analyze-dep-mgt
  Description: This mojo looks at the dependencies after final resolution and
    looks for mismatches in your dependencyManagement section. In versions of
    maven prior to 2.0.6, it was possible to inherit versions that didn't match
    your dependencyManagement. See MNG-1577 for more info. This mojo is also
    useful for just detecting projects that override the dependencyManagement
    directly. Set ignoreDirect to false to detect these otherwise normal
    conditions.

dependency:analyze-duplicate
  Description: Analyzes the <dependencies/> and <dependencyManagement/> tags
    in the pom.xml and determines the duplicate declared dependencies.

... and much more

回答by Jan-Terje S?rensen

Add this to your pom.xmlfile and you will get the result on mvn clean install:

将此添加到您的pom.xml文件中,您将获得以下结果mvn clean install

<plugins>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>versions-maven-plugin</artifactId>
    <version>2.1</version>
    <executions>
      <execution>
        <phase>validate</phase>
        <goals>
           <goal>display-dependency-updates</goal>
           <goal>display-plugin-updates</goal>
           <goal>display-property-updates</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>

If you just want to do it once:

如果你只想做一次:

mvn versions:display-plugin-updates

回答by lovestackh343

You can add an "-X" parameter when maven is packaged(mvn clean compile * -X), and then search for "artifactId" to see the exact version number.

可以-X在maven打包的时候加一个" "参数( mvn clean compile * -X),然后搜索" artifactId"查看确切的版本号。