【Maven】查看插件配置参数

这篇具有很好参考价值的文章主要介绍了【Maven】查看插件配置参数。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

背景

工作中使用到很多的Maven插件,虽然可以从网上拷贝别人的配置来用,但是想要深入了解一个插件一共有哪些可用的配置参数,就无从下手了。

当然可以从插件的官方网站查看帮助手册,也可以通过Mavenhelp命令查看插件帮助,包括插件的简略和详细的描述信息,也可以查看插件所有的目标goal,以及插件的配置参数等。

帮助命令

在命令行下面,使用Mavenhelp:describe目标查看插件信息:mvn help:describe -Dplugin=插件标识

  • 通过plugin参数指定要查看的插件,插件标识可以是groupId:artifactId[:version]形式的,
  • 其中version是可选的,
  • 也可以是插件前缀,
  • 它是插件的简称,
  • 插件前缀和插件是一一对应的,
  • 这种对应关系存储在Maven仓库元数据中:https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml
  • 比如插件前缀help和插件maven-help-plugin是对应的
<plugin>
  <name>Apache Maven Help Plugin</name>
  <prefix>help</prefix>
  <artifactId>maven-help-plugin</artifactId>
</plugin>

使用举例

下面查看maven-help-plugin插件的信息,即查看帮助命令自己的信息,下面两条命令是等价的:

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

输出查询结果如下

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.2.0:describe (default-cli) @ standalone-pom ---
[INFO] org.apache.maven.plugins:maven-help-plugin:3.2.0
 
Name: Apache Maven Help Plugin
Description: The Maven Help plugin provides goals aimed at helping to make
  sense out of the build environment. It includes the ability to view the
  effective POM and settings files, after inheritance and active profiles have
  been applied, as well as a describe a particular plugin goal to give usage
  information.
Group Id: org.apache.maven.plugins
Artifact Id: maven-help-plugin
Version: 3.2.0
Goal Prefix: help
 
This plugin has 8 goals:
 
help:active-profiles
  Description: Displays a list of the profiles which are currently active for
    this build.
 
help:all-profiles
  Description: Displays a list of available profiles under the current
    project.
    Note: it will list all profiles for a project. If a profile comes up with a
    status inactive then there might be a need to set profile activation
    switches/property.
 
help:describe
  Description: Displays a list of the attributes for a Maven Plugin and/or
    goals (aka Mojo - Maven plain Old Java Object).
 
help:effective-pom
  Description: Displays the effective POM as an XML for this build, with the
    active profiles factored in, or a specified artifact. If verbose, a comment
    is added to each XML element describing the origin of the line.
 
help:effective-settings
  Description: Displays the calculated settings as XML for this project,
    given any profile enhancement and the inheritance of the global settings
    into the user-level settings.
 
help:evaluate
  Description: Evaluates Maven expressions given by the user in an
    interactive mode.
 
help:help
  Description: Display help information on maven-help-plugin.
    Call mvn help:help -Ddetail=true -Dgoal=<goal-name> to display parameter
    details.
 
help:system
  Description: Displays a list of the platform details like system properties
    and environment variables.
 
For more information, run 'mvn help:describe [...] -Ddetail'
 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.613 s
[INFO] Finished at: 2021-10-12T15:38:22+08:00
[INFO] ------------------------------------------------------------------------

可以看到maven-help-plugin对应的插件前缀是help

Group Id: org.apache.maven.plugins
Artifact Id: maven-help-plugin
Version: 3.2.0
Goal Prefix: help

可以看到help:describe用来查看插件的属性和目标

help:describe
  Description: Displays a list of the attributes for a Maven Plugin and/or
    goals (aka Mojo - Maven plain Old Java Object).
  • 可以看到help命令自带的帮助: mvn help:help
  • 输出的结果基本和上面的相同
  • 这里更推荐使用help:describe命令

查看详细信息

通过在命令后追加-Ddetail参数,可以查看插件的详细信息:

简略信息:
mvn help:describe -Dplugin=help
详细信息:
mvn help:describe -Dplugin=help -Ddetail

详细信息输出如下,这是可以看到每个goal的配置参数说明

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.2.0:describe (default-cli) @ standalone-pom ---
[INFO] org.apache.maven.plugins:maven-help-plugin:3.2.0
 
Name: Apache Maven Help Plugin
Description: The Maven Help plugin provides goals aimed at helping to make
  sense out of the build environment. It includes the ability to view the
  effective POM and settings files, after inheritance and active profiles have
  been applied, as well as a describe a particular plugin goal to give usage
  information.
Group Id: org.apache.maven.plugins
Artifact Id: maven-help-plugin
Version: 3.2.0
Goal Prefix: help
 
This plugin has 8 goals:
 
help:active-profiles
  Description: Displays a list of the profiles which are currently active for
    this build.
  Implementation: org.apache.maven.plugins.help.ActiveProfilesMojo
  Language: java
 
  Available parameters:
 
    output
      User property: output
      Optional parameter to write the output of this help in a given file,
      instead of writing to the console.
      Note: Could be a relative path.
 
help:all-profiles
  Description: Displays a list of available profiles under the current
    project.
    Note: it will list all profiles for a project. If a profile comes up with a
    status inactive then there might be a need to set profile activation
    switches/property.
  Implementation: org.apache.maven.plugins.help.AllProfilesMojo
  Language: java
 
  Available parameters:
 
    output
      User property: output
      Optional parameter to write the output of this help in a given file,
      instead of writing to the console.
      Note: Could be a relative path.
 
help:describe
  Description: Displays a list of the attributes for a Maven Plugin and/or
    goals (aka Mojo - Maven plain Old Java Object).
  Implementation: org.apache.maven.plugins.help.DescribeMojo
  Language: java
 
  Available parameters:
 
    artifactId
      User property: artifactId
      The Maven Plugin artifactId to describe.
      Note: Should be used with groupId parameter.
 
    cmd
      User property: cmd
      A Maven command like a single goal or a single phase following the Maven
      command line:
      mvn [options] [<goal(s)>] [<phase(s)>]
 
    detail (Default: false)
      User property: detail
      This flag specifies that a detailed (verbose) list of goal (Mojo)
      information should be given.
 
    goal
      User property: goal
      The goal name of a Mojo to describe within the specified Maven Plugin. If
      this parameter is specified, only the corresponding goal (Mojo) will be
      described, rather than the whole Plugin.
 
    groupId
      User property: groupId
      The Maven Plugin groupId to describe.
      Note: Should be used with artifactId parameter.
 
    minimal (Default: false)
      User property: minimal
      This flag specifies that a minimal list of goal (Mojo) information should
      be given.
 
    output
      User property: output
      Optional parameter to write the output of this help in a given file,
      instead of writing to the console.
      Note: Could be a relative path.
 
    plugin
      Alias: prefix
      User property: plugin
      The Maven Plugin to describe. This must be specified in one of three
      ways:
 
      1.  plugin-prefix, i.e. 'help'
      2.  groupId:artifactId, i.e. 'org.apache.maven.plugins:maven-help-plugin'
      3.  groupId:artifactId:version, i.e.
        'org.apache.maven.plugins:maven-help-plugin:2.0'
 
    version
      User property: version
      The Maven Plugin version to describe.
      Note: Should be used with groupId/artifactId parameters.
 
help:effective-pom
  Description: Displays the effective POM as an XML for this build, with the
    active profiles factored in, or a specified artifact. If verbose, a comment
    is added to each XML element describing the origin of the line.
  Implementation: org.apache.maven.plugins.help.EffectivePomMojo
  Language: java
 
  Available parameters:
 
    artifact
      User property: artifact
      The artifact for which to display the effective POM.
      Note: Should respect the Maven format, i.e. groupId:artifactId[:version].
      The latest version of the artifact will be used when no version is
      specified.
 
    output
      User property: output
      Optional parameter to write the output of this help in a given file,
      instead of writing to the console.
      Note: Could be a relative path.
 
    verbose (Default: false)
      User property: verbose
      Output POM input location as comments.
 
help:effective-settings
  Description: Displays the calculated settings as XML for this project,
    given any profile enhancement and the inheritance of the global settings
    into the user-level settings.
  Implementation: org.apache.maven.plugins.help.EffectiveSettingsMojo
  Language: java
 
  Available parameters:
 
    output
      User property: output
      Optional parameter to write the output of this help in a given file,
      instead of writing to the console.
      Note: Could be a relative path.
 
    showPasswords (Default: false)
      User property: showPasswords
      For security reasons, all passwords are hidden by default. Set this to
      true to show all passwords.
 
help:evaluate
  Description: Evaluates Maven expressions given by the user in an
    interactive mode.
  Implementation: org.apache.maven.plugins.help.EvaluateMojo
  Language: java
 
  Available parameters:
 
    artifact
      User property: artifact
      An artifact for evaluating Maven expressions.
      Note: Should respect the Maven format, i.e. groupId:artifactId[:version].
      The latest version of the artifact will be used when no version is
      specified.
 
    expression
      User property: expression
      An expression to evaluate instead of prompting. Note that this must not
      include the surrounding ${...}.
 
    forceStdout (Default: false)
      User property: forceStdout
      This options gives the option to output information in cases where the
      output has been suppressed by using -q (quiet option) in Maven. This is
      useful if you like to use maven-help-plugin:evaluate in a script call
      (for example in bash) like this:
      RESULT=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
      echo $RESULT
      This will only printout the information which has been requested by
      expression to stdout.
 
    output
      User property: output
      Optional parameter to write the output of this help in a given file,
      instead of writing to the console. This parameter will be ignored if no
      expression is specified.
      Note: Could be a relative path.
 
help:help
  Description: Display help information on maven-help-plugin.
    Call mvn help:help -Ddetail=true -Dgoal=<goal-name> to display parameter
    details.
  Implementation: org.apache.maven.plugins.help.HelpMojo
  Language: java
 
  Available parameters:
 
    detail (Default: false)
      User property: detail
      If true, display all settable properties for each goal.
 
    goal
      User property: goal
      The name of the goal for which to show help. If unspecified, all goals
      will be displayed.
 
    indentSize (Default: 2)
      User property: indentSize
      The number of spaces per indentation level, should be positive.
 
    lineLength (Default: 80)
      User property: lineLength
      The maximum length of a display line, should be positive.
 
help:system
  Description: Displays a list of the platform details like system properties
    and environment variables.
  Implementation: org.apache.maven.plugins.help.SystemMojo
  Language: java
 
  Available parameters:
 
    output
      User property: output
      Optional parameter to write the output of this help in a given file,
      instead of writing to the console.
      Note: Could be a relative path.
 
 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.904 s
[INFO] Finished at: 2021-10-12T15:53:53+08:00
[INFO] ------------------------------------------------------------------------

查看指定目标

可以通过-Dgoal参数,查看指定目标的详细信息:

简略信息:
mvn help:describe -Dplugin=help -Dgoal=describe
详细信息:
mvn help:describe -Dplugin=help -Dgoal=describe -Ddetail

简略信息输出如下

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.2.0:describe (default-cli) @ standalone-pom ---
[INFO] Mojo: 'help:describe'
help:describe
  Description: Displays a list of the attributes for a Maven Plugin and/or
    goals (aka Mojo - Maven plain Old Java Object).
 
For more information, run 'mvn help:describe [...] -Ddetail'
 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.031 s
[INFO] Finished at: 2021-10-12T15:56:50+08:00
[INFO] ------------------------------------------------------------------------

详细信息输出如下

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.2.0:describe (default-cli) @ standalone-pom ---
[INFO] Mojo: 'help:describe'
help:describe
  Description: Displays a list of the attributes for a Maven Plugin and/or
    goals (aka Mojo - Maven plain Old Java Object).
  Implementation: org.apache.maven.plugins.help.DescribeMojo
  Language: java
 
  Available parameters:
 
    artifactId
      User property: artifactId
      The Maven Plugin artifactId to describe.
      Note: Should be used with groupId parameter.
 
    cmd
      User property: cmd
      A Maven command like a single goal or a single phase following the Maven
      command line:
      mvn [options] [<goal(s)>] [<phase(s)>]
 
    detail (Default: false)
      User property: detail
      This flag specifies that a detailed (verbose) list of goal (Mojo)
      information should be given.
 
    goal
      User property: goal
      The goal name of a Mojo to describe within the specified Maven Plugin. If
      this parameter is specified, only the corresponding goal (Mojo) will be
      described, rather than the whole Plugin.
 
    groupId
      User property: groupId
      The Maven Plugin groupId to describe.
      Note: Should be used with artifactId parameter.
 
    minimal (Default: false)
      User property: minimal
      This flag specifies that a minimal list of goal (Mojo) information should
      be given.
 
    output
      User property: output
      Optional parameter to write the output of this help in a given file,
      instead of writing to the console.
      Note: Could be a relative path.
 
    plugin
      Alias: prefix
      User property: plugin
      The Maven Plugin to describe. This must be specified in one of three
      ways:
 
      1.  plugin-prefix, i.e. 'help'
      2.  groupId:artifactId, i.e. 'org.apache.maven.plugins:maven-help-plugin'
      3.  groupId:artifactId:version, i.e.
        'org.apache.maven.plugins:maven-help-plugin:2.0'
 
    version
      User property: version
      The Maven Plugin version to describe.
      Note: Should be used with groupId/artifactId parameters.
 
 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.162 s
[INFO] Finished at: 2021-10-12T15:57:13+08:00
[INFO] ------------------------------------------------------------------------

其他命令

该帮助插件还有很多有用的goal,下面仅列出几个常用的,更多的请自行尝试。文章来源地址https://www.toymoban.com/news/detail-617417.html

  • 查看当前pom.xml具体生效的结果,并且输出到文件: mvn help:effective-pom -Doutput=EffectivePom.xml
  • 查看pom中生效的profile: mvn help:active-profiles -N
  • 查看系统所有环境变量: mvn help:system

到了这里,关于【Maven】查看插件配置参数的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 用Intellij/Maven插件查看测试覆盖率和测试报告

    目录 概览 Intellij Maven 配置 查看测试报告 用maven插件 用Jacoco (Java Code Coverage)

    2024年02月15日
    浏览(43)
  • Idea使用Docker插件实现maven打包自动构建镜像

    Docker 开启TCP 服务 改写以下内容 重启服务 此时docker已经开放了2375端口,使用外部主机访问 http://docker:2375/info IDEA 集成Docker 安装Docker 插件 配置docker服务地址 点击view-services,打开docker的操作面板 双击docker01可以看到此docker服务下镜像和容器 右击docker镜像,可以创建新的容器,

    2024年02月10日
    浏览(47)
  • Maven项目构建工具

    目录         1.Maven介绍                 1.1Maven是什么                 1.2为什么要使用maven         2.Maven安装                 2.1下载Maven:                 2.2解压并配置                 2.3编辑Maven环境变量               

    2024年01月20日
    浏览(43)
  • 【Maven教程】(一)入门介绍篇:Maven基础概念与其他构建工具:理解构建过程与Maven的多重作用,以及与敏捷开发的关系 ~

    \\\" Maven \\\"可以翻译为 “知识的积累者” 或 “专家”。这个词源于波斯语,意为广受尊重和富有智慧的人。在软件开发领域中,Maven作为Apache 组织中的一个颇为成功的开源项目,它是一个非常流行的构建工具,它在项目管理、依赖管理和构建自动化方面提供了强大的功能和支持

    2024年02月12日
    浏览(46)
  • Spring Boot各版本与Java版本的对应兼容关系,与构建工具(Maven、Gradle)版本的对应兼容关系,对servlet 容器的支持

    by:垃圾程序员 当前文章具有时效性,在当前springboot的版本下做的整合。之后大家视情况可以直接到Spring的官网查看 Spring | Home Level up your Java code and explore what Spring can do for you. https://spring.io/ 下面是Spring Boot各个版本的支持时间 下面是Spring Boot 推荐使用的各个版面,并标注出

    2024年02月10日
    浏览(49)
  • 使用docker-maven-plugin插件构建镜像并推送至私服Harbor

    如下所示,建议使用 Dockerfile Maven 插件,但该插件也停止维护更新了。因此先暂时使用 docker-maven-plugin 插件。 默认的dokcer是不支持远程访问的,需要加点配置,开启Docker的远程访问 确定docker配置文件位置在:/etc/systemd/system/docker.service 然后编辑修改docker配置文件: 找到包含

    2024年02月11日
    浏览(60)
  • 新一代构建工具 maven-mvnd

    maven 作为一代经典的构建工具,流行了很多年,知道现在依然是大部分Java项目的构建工具的首选;但随着项目复杂度提高,代码量及依赖库的增多使得maven在大型项目的构建的速度上被人诟病。 因此推出了gradle之类的项目,虽然gradle在构建效率是高于maven,但是在一般的小项

    2024年02月14日
    浏览(44)
  • Maven的安装、配置以及在Eclipse中安装maven插件

    一、需要准备的东西 (原文链接) 1.首先确保安装了JDK,并且成功配置了JDK的环境变量。 2. 已安装Eclipse 3. Maven程序包 二、maven下载与安装 1. 前往https://maven.apache.org/download.cgi下载最新版的Maven程序: 2. 将文件解压到D:Program FilesApachemaven目录下: 3. 新建环境变量MAVEN_HOME,赋值

    2023年04月14日
    浏览(57)
  • Jenkins——maven 插件配置

    在 Jenkins 上构建 Java 项目时需要使用 Maven 来进行构建打包 1、下载 maven 程序压缩包 2、解压 maven 压缩包 3、配置环境变量 详细操作步骤: https://blog.csdn.net/YZL40514131/article/details/130080838 1、进入菜单 Dashboard——》系统管理(Manage Jenkins)——》插件管理(Manage Plugins) 2、在可选

    2024年02月09日
    浏览(53)
  • 【Docker】使用docker-maven-plugin插件构建发布推镜像到私有仓库

    本文描述了在Spring Boot项目中通过docker-maven-plugin插件把项目推送到私有docker仓库中,随后拉取仓库中的项目用docker run运行项目。作者自行构建,质量有保证。 1、要想使用 docker-maven-plugin ,需要在 pom.xml 中添加该插件; 注:注意下db:3306 2、我们构建镜像之前需要先将项目打包

    2024年02月15日
    浏览(47)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包