本文主要说明如何使用maven的help插件查看其他maven插件提供的goal信息。

maven项目的构建生命周期(build lifecycle)由很多阶段组成:从validate到deploy。

maven插件中包含goal。这些goal可以被绑定到不同的maven的构建阶段上。goal表示一个特定的任务,是一个比构建阶段更细粒度的构建步骤,用于构建和管理当前项目。

要使用maven插件提供的goal,首先得知道这些插件提供了哪些goal以及他们的用法。

maven的核心插件之一 --- help插件(Maven Help Plugin)可以用于查看插件提供了哪些goal。

以下是maven help插件的概述信息:

The Maven Help Plugin is used to get relative information about a project or the system. It can be used to get a description of a particular plugin, including the plugin's mojos with their parameters and component requirements, the effective POM and effective settings of the current build, and the profiles applied to the current project being built.

关于maven help插件的详细信息请参考Maven Help Plugin页面。此处,仅举例说明如何使用help插件查看plugin goal的信息。

以maven-eclipse-plugin为例,举例说明。

1,首先在pom.xml文件中配置插件。

<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.10</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<wtpversion>2.0</wtpversion>
<wtpContextName>spring3</wtpContextName>
</configuration>
</plugin>
</plugins>
</build>
</project>

2,从命令行进入项目所在路径(pom.xml所在的路径)。

3,按如下格式执行命令:

mvn help:describe -Dplugin=groupId:artifactId:version

如:

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

然后回车,则输出如下信息:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building development 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.2:describe (default-cli) @ development ---
[INFO] org.apache.maven.plugins:maven-eclipse-plugin:2.10

Name: Apache Maven Eclipse Plugin
Description: The Eclipse Plugin is used to generate Eclipse IDE files
  (.project, .classpath and the .settings folder) from a POM.
Group Id: org.apache.maven.plugins
Artifact Id: maven-eclipse-plugin
Version: 2.10
Goal Prefix: eclipse

This plugin has 12 goals:

eclipse:clean
  Description: Deletes the .project, .classpath, .wtpmodules files and
    .settings folder used by Eclipse.

eclipse:configure-workspace
  Description: Configures The following Eclipse Workspace features:
    - Adds the classpath variable MAVEN_REPO to Eclipse.
    - Optionally load Eclipse code style file via a URL.

eclipse:eclipse
  Description: Generates the following eclipse configuration files:
    - .project and .classpath files
    - .setting/org.eclipse.jdt.core.prefs with project specific compiler
      settings
    - various configuration files for WTP (Web Tools Project), if the parameter
      wtpversion is set to a valid version (WTP configuration is not generated
      by default)
    If this goal is run on a multiproject root, dependencies between modules
    will be configured as direct project dependencies in Eclipse (unless
    useProjectReferences is set to false).

eclipse:help
  Description: Display help information on maven-eclipse-plugin.
    Call mvn eclipse:help -Ddetail=true -Dgoal=<goal-name> to display parameter
    details.

eclipse:install-plugins
  Description: Install plugins resolved from the Maven repository system into
    an Eclipse instance.

eclipse:myeclipse
  Description: Generates MyEclipse configuration files

eclipse:myeclipse-clean
  Description: Deletes configuration files used by MyEclipse

eclipse:rad
  Description: Generates the rad-6 configuration files.

eclipse:rad-clean
  Description: Deletes the config files used by Rad-6. the files .j2ee and
    the file .websettings

eclipse:remove-cache
  Description: Removes the not-available marker files from the repository.

eclipse:resolve-workspace-dependencies
  Description: For all projects currently part of the workspace, all
    references to the M2_REPO classpath variable are resolved.
    Note: not the projects of the reactor are inspected for unresolved
    artifacts, but the projects that are part of the workspace.

eclipse:to-maven
  Description: Add eclipse artifacts from an eclipse installation to the
    local repo. This mojo automatically analize the eclipse directory, copy
    plugins jars to the local maven repo, and generates appropriate poms. This
    is the official central repository builder for Eclipse plugins, so it has
    the necessary default values. For customized repositories see
    MakeArtifactsMojo Typical usage: mvn eclipse:to-maven
    -DdeployTo=maven.org::default::scpexe://repo1.maven.org/home/maven/repository-staging/to-ibiblio/eclipse-staging
    -DeclipseDir=.

For more information, run 'mvn help:describe [...] -Ddetail'

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.887 s
[INFO] Finished at: 2017-09-22T11:10:52+08:00
[INFO] Final Memory: 11M/150M
[INFO] ------------------------------------------------------------------------

如何查看maven plugin所包含的goal的更多相关文章

  1. Spring Boot的Maven插件Spring Boot Maven plugin详解

    Spring Boot的Maven插件(Spring Boot Maven plugin)能够以Maven的方式为应用提供Spring Boot的支持,即为Spring Boot应用提供了执行Mave ...

  2. 查看maven项目的依赖关系 mvn dependency:tree

    maven-dependency-plugin最大的用途是帮助分析项目依赖,dependency:list能够列出项目最终解析到的依赖列表,dependency:tree能进一步的描绘项目依赖树,de ...

  3. 学习Maven之Cobertura Maven Plugin

    cobertura-maven-plugin是个什么鬼? cobertura-maven-plugin是一个校验单元测试用例覆盖率的工具,可以生成一个测试覆盖率报告,可以给单元测试用例编写提供参考. ...

  4. Spring Boot Maven Plugin打包异常及三种解决方法:Unable to find main class

    [背景]spring-boot项目,打包成可执行jar,项目内有两个带有main方法的类并且都使用了@SpringBootApplication注解(或者另一种情形:你有两个main方法并且所在类都没 ...

  5. tomcat:run和tomcat7:run的区别,以及Apache Tomcat Maven Plugin 相关

    起因: 同事部署的maven项目,之前使用 jetty,现在切换到 tomcat,但是他使用的命令是 tomcat:run ,而不是 tomcat7:run,能启动,但出现问题了. 于是搜索了一番,想 ...

  6. Maven实现Web应用集成測试自己主动化 -- 部署自己主动化(WebTest Maven Plugin)

    上篇:Maven实现Web应用集成測试自己主动化 -- 測试自己主动化(WebTest Maven Plugin) 之前介绍了怎样在maven中使用webtest插件实现web的集成測试,这里有个遗留 ...

  7. Spring Boot Maven Plugin(一):repackage目标

    简介 Spring Boot Maven Plugin插件提供spring boot在maven中的支持.允许你打包可运行的jar包或war包. 插件提供了几个maven目标和Spring Boot ...

  8. Intellij IDEA 中如何查看maven项目中所有jar包的依赖关系图(转载)

    Intellij IDEA 中如何查看maven项目中所有jar包的依赖关系图 2017年04月05日 10:53:13 李学凯 阅读数:104997更多 所属专栏: Intellij Idea   ...

  9. Error : Weblogic Maven Plugin deployment WebLogic 12c

    Error : Weblogic Maven Plugin deployment i want to use weblogic-maven-plugin in my maven project in ...

随机推荐

  1. eclipse中使用Maven管理java工程设置jdk版本为jdk1.8

    使用Maven管理Java工程时,maven可以自动下载工程中依赖的jar包,这对于大型的项目非常方便.但在初次使用eclipse新建maven工程时遇到一些问题,我的jdk安装的是1.8版本,在配置 ...

  2. 【Centos 7】使用screen恢复终端连接

    操作系统:centos7.1 (在ubuntu上测试过,不支持 screen) 主机:虚拟云主机 问题出现:在使用打包式在线安装phpstudy时,由于安装过程非常漫长,http报文过一段时间没有回送 ...

  3. Apache Kafka系列(五) Kafka Connect及FileConnector示例

    Apache Kafka系列(一) 起步 Apache Kafka系列(二) 命令行工具(CLI) Apache Kafka系列(三) Java API使用 Apache Kafka系列(四) 多线程 ...

  4. 线性代数-矩阵-【3】矩阵加减 C和C++实现

    点击这里可以跳转至 [1]矩阵汇总:http://www.cnblogs.com/HongYi-Liang/p/7287369.html [2]矩阵生成:http://www.cnblogs.com/ ...

  5. hdu 6107--Typesetting(倍增)

    题目链接 Problem Description Yellowstar is writing an article that contains N words and 1 picture, and t ...

  6. 堆排序—Java

    堆排序: 一棵完全二叉树,如果父节点的值大于等于左右节点的值,则称此完全二叉树为小根堆(小顶堆):如果父节点的值小于等于左右节点的值,则次完全二叉树为大根堆(大顶堆). 堆排序是建立在大顶堆或小顶堆的 ...

  7. String 操作

    String nbbms ="col_1_1_1_1,col_2_2_2_@,"; @ 实现将最后一个逗号去掉:从第一个字符串到最后一个逗号之前的字符串截取[java] Strin ...

  8. [js高手之路]深入浅出webpack系列1-安装与基本打包用法和命令参数

    webpack,我想大家应该都知道或者听过,Webpack是前端一个工具,可以让各个模块进行加载,预处理,再进行打包.现代的前端开发很多环境都依赖webpack构建,比如vue官方就推荐使用webpa ...

  9. httpd常用配置

    author:JevonWei 版权声明:原创作品 检查配置文件时,如下提示,则因为没有server的服务名称导致,故设置网站的服务server名称,若没有设置web服务名,主默认解析系统主机名(添加 ...

  10. vue2+swiper(用户操作swiper后,不能autoplay了)

    将autoplayDisableOnInteraction设置为false