maven 的plugin 的使用
mvn [plugin-name]:[goal-name]
mvn compiler:compile 这里写的十分详细: https://www.tutorialspoint.com/maven/maven_quick_guide.htm
--------------------------------------------
What are Maven Plugins?
Maven is actually a plugin execution framework where every task is actually done by plugins. Maven Plugins are generally used to −
- create jar file
- create war file
- compile code files
- unit testing of code
- create project documentation
- create project reports
A plugin generally provides a set of goals, which can be executed using the following syntax −
mvn [plugin-name]:[goal-name]
For example, a Java project can be compiled with the maven-compiler-plugin's compile-goal by running the following command.
mvn compiler:compile
Plugin Types
Maven provided the following two types of Plugins −
| Sr.No. | Type & Description |
|---|---|
| 1 |
Build plugins They execute during the build process and should be configured in the <build/> element of pom.xml. |
| 2 |
Reporting plugins They execute during the site generation process and they should be configured in the <reporting/> element of the pom.xml. |
Following is the list of few common plugins −
| Sr.No. | Plugin & Description |
|---|---|
| 1 |
clean Cleans up target after the build. Deletes the target directory. |
| 2 |
compiler Compiles Java source files. |
| 3 |
surefire Runs the JUnit unit tests. Creates test reports. |
| 4 |
jar Builds a JAR file from the current project. |
| 5 |
war Builds a WAR file from the current project. |
| 6 |
javadoc Generates Javadoc for the project. |
| 7 |
antrun Runs a set of ant tasks from any phase mentioned of the build. |
Example
We've used maven-antrun-plugin extensively in our examples to print data on console. Refer Build Profiles chapter. Let us understand it in a better way and create a pom.xml in C:\MVN\project folder.
<project xmlns = "http://maven.apache.org/POM/4.0.0"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.companyname.projectgroup</groupId>
<artifactId>project</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>id.clean</id>
<phase>clean</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>clean phase</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Next, open the command console and go to the folder containing pom.xml and execute the following mvn command.
C:\MVN\project>mvn clean
Maven will start processing and displaying the clean phase of clean life cycle
maven 的plugin 的使用的更多相关文章
- 学习Maven之Maven Enforcer Plugin
1.Maven Enforcer plugin是什么鬼? 在说这个插件是什么前我们先思考这么一个问题:当我们开发人员进入项目组进行开发前,要准备开发环境,而领导总是会强调工具的统一,编译环境的统一.比 ...
- [Maven] - Eclipse "maven compiler plugin" 冲突解决
刚安装最新的Maven 3.2.5,在eclipse中使用maven的Run As->Maven Install,总会提示: Failed to execute goal org.apache. ...
- [Apache Maven Shade Plugin] [example] [001] 官方例子:includes-excludes
链接地址:[Selecting Contents for Uber JAR](http://maven.apache.org/plugins/maven-shade-plugin/examples/i ...
- maven jetty plugin
转载:http://blog.163.com/xueling1231989@126/blog/static/1026408072013101311395492/ 前言: 在 maven 下测试调试时, ...
- 施用 maven shade plugin 解决 jar 或类的多版本冲突
施用 maven shade plugin 解决 jar 或类的多版本冲突 使用 maven shade plugin 解决 jar 或类的多版本冲突java 应用经常会碰到的依赖的三方库出现版本 ...
- 解决Maven出现Plugin execution not covered by lifecycle configuration 错误
http://blog.163.com/xh_ding/blog/static/1939032892015222368827/ 解决Maven出现Plugin execution not covere ...
- Jenkins安装maven integration plugin失败解决方法
最近装了一个jenkins准备搞一个自动化测试的持续集成,但是在安装maven integration这个插件时报错,试了几次都是失败! 错误原因如下: javadoc安装失败: java.io.IO ...
- 记录一次maven打包时将test目录下的类打包到jar中,Maven Assembly Plugin的使用
今天有人问我打包后找不到主类,运行的类写在test中.按照常规,test目录下的文件不会打包到jar包中.(但是我测试一个springboot工程就可以,这里之后再研究) 具体解决如下 第一步:在po ...
- 学习Maven之Maven Clean Plugin
1.maven-clean-plugin是个什么鬼? maven-clean-plugin这个插件用maven的人都不陌生.我们在执行命令mvn clean时调用的就是这个插件. 这个插件的主要作用就 ...
- 学习Maven之Maven Surefire Plugin(JUnit篇)
1.maven-surefire-plugin是个什么鬼? 如果你执行过mvn test或者执行其他maven命令时跑了测试用例,你就已经用过maven-surefire-plugin了.maven- ...
随机推荐
- Ambari架构及安装
不多说,直接上干货! 1.什么是Ambari? 2.Ambari项目是由哪几部分构成的? 3.Ambari系统架构是如何组成的? 前言 Hadoop集群的管控一直是一个热门的话题,对于这样的一个应用场 ...
- Java引用jar的优化
一般java的类文件开头都是各种引用: 如 上图的引用可以写成
- sql server 大数据跨服务器迁移表数据——使用链接服务器
1.创建链接服务器(填写链接服务器.远程登录.使用密码) 2.188.188.1.177是远程的 select count(*) from [188.188.1.177].BigDataAnalysi ...
- 控制台——args参数的赋值方法
args参数的赋值方法有好几种,主要介绍两种. 外部传参的方法:先找到bin目录下的exe文件,并创建快捷方法,在目标后面追加参数. 控制台主函数入口实现方法 static void Main(str ...
- Linux 一些小知识点汇总(持续更新....)
一.符号 1.$@:传递的参数. 2.$# :传递参数的数量. 3.$?:指上一次执行命令后的返回值.一般0表示运行成功. 补充:$?只表示上一个命令执行后的退出状态,当命令执行后,又执行了其他命令, ...
- 可以用作javascript异步模式的函数写法
1. 回调函数 f1(); f2(); function f1(callback) { setTimeout(function() { // f1的任务代码 callback(); }, 1000); ...
- 爬虫文件存储-2:MongoDB
1.连接MongoDB 连接 MongoDB 我们需要使用 PyMongo 库里面的 MongoClient,一般来说传入 MongoDB 的 IP 及端口即可,第一个参数为地址 host,第二个参数 ...
- 39.date hitogram基础知识
主要知识点: date hitogram之统计每月电视销量 上一节讲到histogram,他是以数值进行分组.本节讲到以日期进行bucket分组操作,也就是说把连续的日期变成离散的日期区间,然 ...
- 33.bucket与metric核心概念讲解
主要知识点: bucket与metric核心慨念 一.核心慨念 1.bucket:一个数据分组 比如有下面几条数据: city name 北京 小李 北京 小王 上海 小张 上海 小丽 上海 小陈 ...
- npm和gulp学习
npm的使用 node Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境,是一种JavaScript语言运行平台,和浏览器这个运行平台是同一个概念. npm np ...