mvn -h显示mvn命令帮助:

usage: mvn [options] [<goal(s)>] [<phase(s)>]

Options:
-am,--also-make If project list is specified, also
build projects required by the
list
-amd,--also-make-dependents If project list is specified, also
build projects that depend on
projects on the list
-B,--batch-mode Run in non-interactive (batch)
mode
-b,--builder <arg> The id of the build strategy to
use.
-C,--strict-checksums Fail the build if checksums don't
match
-c,--lax-checksums Warn if checksums don't match
-cpu,--check-plugin-updates Ineffective, only kept for
backward compatibility
-D,--define <arg> Define a system property
-e,--errors Produce execution error messages
-emp,--encrypt-master-password <arg> Encrypt master security password
-ep,--encrypt-password <arg> Encrypt server password
-f,--file <arg> Force the use of an alternate POM
file (or directory with pom.xml).
-fae,--fail-at-end Only fail the build afterwards;
allow all non-impacted builds to
continue
-ff,--fail-fast Stop at first failure in
reactorized builds
-fn,--fail-never NEVER fail the build, regardless
of project result
-gs,--global-settings <arg> Alternate path for the global
settings file
-h,--help Display help information
-l,--log-file <arg> Log file to where all build output
will go.
-llr,--legacy-local-repository Use Maven 2 Legacy Local
Repository behaviour, ie no use of
_remote.repositories. Can also be
activated by using
-Dmaven.legacyLocalRepo=true
-N,--non-recursive Do not recurse into sub-projects
-npr,--no-plugin-registry Ineffective, only kept for
backward compatibility
-npu,--no-plugin-updates Ineffective, only kept for
backward compatibility
-nsu,--no-snapshot-updates Suppress SNAPSHOT updates
-o,--offline Work offline
-P,--activate-profiles <arg> Comma-delimited list of profiles
to activate
-pl,--projects <arg> Comma-delimited list of specified
reactor projects to build instead
of all projects. A project can be
specified by [groupId]:artifactId
or by its relative path.
-q,--quiet Quiet output - only show errors
-rf,--resume-from <arg> Resume reactor from specified
project
-s,--settings <arg> Alternate path for the user
settings file
-T,--threads <arg> Thread count, for instance 2.0C
where C is core multiplied
-t,--toolchains <arg> Alternate path for the user
toolchains file
-U,--update-snapshots Forces a check for missing
releases and updated snapshots on
remote repositories
-up,--update-plugins Ineffective, only kept for
backward compatibility
-V,--show-version Display version information
WITHOUT stopping build
-v,--version Display version information
-X,--debug Produce execution debug output

goal和phase分别指插件目标和生命周期阶段。

我们知道,可以通过mvn命令激活生命周期阶段,从而执行那些绑定在生命周期阶段上的插件目标。但Maven还支持直接从命令行调用插件目标。Maven支持这种方式是因为有些任务不适合绑定在生命周期上,例如maven-help-plugin:describe,我们不需要在构建项目的时候去描述插件信息。又如maven-dependency-plugin:tree,我们也不需要在构建项目的时候去显示依赖树。因此这些插件目标应该通过如下方式使用:

$ mvn help:describe -Dplugin=compiler

$ mvn dependency:tree

不过,这里还有一个疑问,describe是maven-help-plugin的目标没错,但冒号前面的help是什么呢?它既不是groupId,也不是artifactId,Maven是如何根据该信息找到对应版本插件的呢?同理,为什么不是maven-dependency-plugin:tree而是dependency:tree呢?

解答该疑问之前,可以先尝试一下如下的命令:

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

$ mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:tree

这两条命令就比较容易理解了。它们的效果与之前的两条命令基本是一样的,但显然前面的命令更简洁,更容易记忆和使用。为了达到该目的,Maven引入了目标前缀的概念。help是maven-help-plugin的目标前缀,dependency是maven-dependency-plugin的目标前缀,有了插件前缀,Maven就能找到对应的artifactId。不过仅有artifactId,而没有groupId和version,Maven是无法精确定位到某个插件的。那么,Maven是如何做到的呢?我们将在后面的文章详细剖析这个问题。

Maven-11: 从命令行调用插件的更多相关文章

  1. Java项目导出为jar包+导出第三方jar包+使用命令行调用+传参

    Java项目导出为jar包+导出第三方jar包+使用命令行调用+传参 一.打包 情况1:不需要向程序传参数,并且程序没有使用第三方jar包 Eclipse上导出jar: 然后选择一个java文件作为入 ...

  2. Symfony2 通过命令行调用控制器

    由于系统需求,需要写一个无限循环的控制器,那么既然有一个无限循环的控制器,那么就需要有一个开关,不可能直接通过route来开启吧.当然要使用高级一点的方法啊. 那就是使用控制台通过命令行(comman ...

  3. 命令行调用dubbo远程服务

    命令行调用dubbo远程服务 telnet远程连接到dubbo telnet 127.0.0.1 20880 查看提供服务的接口 dubbo>ls com.test.service.TestIn ...

  4. VB6 实现命令行调用时附着到原控制台

    Public Declare Function AttachConsole Lib "kernel32.dll" (ByVal ProcessID As Integer) As B ...

  5. blockdev - 从命令行调用区块设备控制程序

    总览(SYNOPSIS) blockdev [options] commands devices 描述(DESCRIPTION) blockdev 工具允许从命令行调用区块设备控制程序. 选项(OPT ...

  6. Shodan搜索引擎详解及Python命令行调用

    shodan常用信息搜索命令 shodan配置命令 shodan init T1N3uP0Lyeq5w0wxxxxxxxxxxxxxxx //API设置 shodan信息收集 shodan myip ...

  7. Linux中级之ansible概念及hoc命令行调用模式

    一.Ansible简介 ansible是新出现的开源的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fabric)的优点,实现了批量系统 ...

  8. 软工+C(11): 从命令行开始逐步培养编程能力(Java)

    上一篇:助教指南,持续更新... // Version: 0.0.4 许多人,所不知道的是,每一种编程语言都有其对应的单元测试框架,对程序在不同阶段的测试环节也概念模糊.在实际动手编写程序许久之后才听 ...

  9. 使用Ant 和 Maven打包发布命令行程序(转载)

    From:https://www.linux178.com/Java/maven-release.html 用Java写了一个命令行的小程序,使用的Intellij IDE是IDEA13原来一直使用A ...

随机推荐

  1. 左连接条件与where条件的区别

    Sql 查询语句应用左连接时的链接条件中经常加一些常量值在里面如: "On a.id= b.id and b.is_del =0 and b.is_old =1" 这种条件如果加在 ...

  2. Linux基础四

    vim编辑器 vi编辑器的增强版,语法高亮等扩展功能 vim三种工作模式  a,i,o等键输出模式 命令模式,输入模式,末行模式 模式间的切换 a:当前行插入 i:当前行插入 o:全新一行插入 :键末 ...

  3. javascript-深入理解&&和||

    先从两个问题看起: 第一个问题 为什么 a && b 返回的是true,b && a 返回的是6 var user = 6; var both = true; cons ...

  4. Centos 6.5升级openssh漏洞

    CentOS 6.5下openssh升级 在有的企业中每年都会安全扫描,因为实现远程连接比较重要,如果openssh版本过低,就要对其升级,本文主要讲述openssh升级的步骤. openssh升级主 ...

  5. Ubutu Chrome 出现adobe flash is out of date的解决方法

    我们需要到官网下载flash player,网址:https://get.adobe.com/flashplayer/ 不过这里要说明一下: 一般的浏览器使用的是npapi,即adobe flash ...

  6. Java之split方法

    Java之split方法 1.间隔号"." (1)str.split(".") String str = "10.156.35.87"; S ...

  7. CentOS中配置NFS服务

    1.服务器端安装rpcbind.nfs-utils.nfs-server包 yum install nfs-utils -y 2.修改服务器端配置文件,添加需要共享的文件夹. vim /etc/exp ...

  8. 微信小程序之上传下载交互api

    wx.request(OBJECT) OBJECT参数说明: 参数名 类型 必填 说明 url String 是 开发者服务器接口地址 data Object.String 否 请求的参数 heade ...

  9. 加深try catch Finnly的理解

    上代码 public String twoGetFeeInfoByWithUnit(JSONArray jsonArray,String key1,String key2){ String Debit ...

  10. Dynamics 365中审核用户权限变化的一种方法

    摘要: 本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复268或者20180311可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyon ...