Maven-11: 从命令行调用插件
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: 从命令行调用插件的更多相关文章
- Java项目导出为jar包+导出第三方jar包+使用命令行调用+传参
Java项目导出为jar包+导出第三方jar包+使用命令行调用+传参 一.打包 情况1:不需要向程序传参数,并且程序没有使用第三方jar包 Eclipse上导出jar: 然后选择一个java文件作为入 ...
- Symfony2 通过命令行调用控制器
由于系统需求,需要写一个无限循环的控制器,那么既然有一个无限循环的控制器,那么就需要有一个开关,不可能直接通过route来开启吧.当然要使用高级一点的方法啊. 那就是使用控制台通过命令行(comman ...
- 命令行调用dubbo远程服务
命令行调用dubbo远程服务 telnet远程连接到dubbo telnet 127.0.0.1 20880 查看提供服务的接口 dubbo>ls com.test.service.TestIn ...
- VB6 实现命令行调用时附着到原控制台
Public Declare Function AttachConsole Lib "kernel32.dll" (ByVal ProcessID As Integer) As B ...
- blockdev - 从命令行调用区块设备控制程序
总览(SYNOPSIS) blockdev [options] commands devices 描述(DESCRIPTION) blockdev 工具允许从命令行调用区块设备控制程序. 选项(OPT ...
- Shodan搜索引擎详解及Python命令行调用
shodan常用信息搜索命令 shodan配置命令 shodan init T1N3uP0Lyeq5w0wxxxxxxxxxxxxxxx //API设置 shodan信息收集 shodan myip ...
- Linux中级之ansible概念及hoc命令行调用模式
一.Ansible简介 ansible是新出现的开源的自动化运维工具,基于Python开发,集合了众多运维工具(puppet.cfengine.chef.func.fabric)的优点,实现了批量系统 ...
- 软工+C(11): 从命令行开始逐步培养编程能力(Java)
上一篇:助教指南,持续更新... // Version: 0.0.4 许多人,所不知道的是,每一种编程语言都有其对应的单元测试框架,对程序在不同阶段的测试环节也概念模糊.在实际动手编写程序许久之后才听 ...
- 使用Ant 和 Maven打包发布命令行程序(转载)
From:https://www.linux178.com/Java/maven-release.html 用Java写了一个命令行的小程序,使用的Intellij IDE是IDEA13原来一直使用A ...
随机推荐
- 从零开始学习前端JAVASCRIPT — 14、闭包与继承
一.闭包 1 . 概念:闭包就是能够读取其他函数内部变量的函数.在JS中,只有函数内部的子函数才能读取局部变量,因此可以把闭包简单理解为”定义在一个函数内部的函数”. 2 . 闭包的特点 1)可以读取 ...
- GJB150-2009军用装备实验室环境试验方法新版标准
http://www.kekaoxing.com/m/view.php?aid=22604 GJB150.1A-2009 军用装备实验室环境试验方法第1部分:通用要求(代替GJB150.1-86)GJ ...
- zTree实现地市县三级级联Service接口测试
zTree实现地市县三级级联Service接口测试 ProvinceServiceTest.java: /** * @Title:ProvinceServiceTest.java * @Package ...
- MySQL查询所有数据库表出错
1.错误描述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:show tables 错误代码: 1046 No database sel ...
- java.lang.Exception: Socket bind failed
1.错误描述 严重: Failed to initialize end point associated with ProtocolHandler ["http-apr-8080" ...
- java类型转换详解(自动转换和强制转换)
自动转换 class Hello { public static void main(String[] args) { //自动转换 int a = 5; byte b = 6; int c = a ...
- jsTree树形菜单分类
这里我演示的jsTree是基于ABP框架 ,展示部分代码,话不多说首先看效果如: 1:引入JS <link href="/jstree/themes/default/style.css ...
- 【Luogu2711】小行星(网络流,最大流)
[Luogu2711]小行星(网络流,最大流) 题面 题目描述 星云中有n颗行星,每颗行星的位置是(x,y,z).每次可以消除一个面(即x,y或z坐标相等)的行星,但是由于时间有限,求消除这些行星的最 ...
- 【HNOI2004】宠物收养所(splay)
题面 Description 最近,阿Q开了一间宠物收养所.收养所提供两种服务:收养被主人遗弃的宠物和让新的主人领养这些宠物.每个领养者都希望领养到自己满意的宠物,阿Q根据领养者的要求通过他自己发明的 ...
- [BZOJ3110][ZJOI2013]K大数查询(整体二分)
BZOJ Luogu sol 整体二分,其实很简单的啦. 对所有询问二分一个答案mid,把所有修改操作中数字大于mid的做一个区间覆盖(区间加1) 查询就是区间查询 然后左右分一分即可 注意是第k大 ...