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- ...
随机推荐
- fcc 响应式框架Bootstrap 练习2
text-primary 属性值使标题直接变成了红色,text-center使标题直接居中 <h2 class="text-primary text-center"> ...
- wampserver修改mysql数据库密码的简单方式
刚装好的wampserver的数据库是没有密码的,所以可以直接登录,要设置密码,一种简单的方式如下: 打开phpMyadmin 初始状态没有密码,可以直接登录 登录之后,点击账户 点击修改权限,设置你 ...
- IC验证概念总结
一份代码,在写完之后,一定要再经过一次或多次整理和打磨,才能算完成的:一份代码,一定要把其有效代码行,精简.锤炼到最少.最短.最有效,才能算完成的. 下面这些问题和回答是忘记是在哪里看到的了,参考 ...
- printFinal用法示例
printFinal是一个基于jQuery的打印插件,支持打印预览,使用很简单,废话不多多说,直接上代码. <!DOCTYPE html PUBLIC "-//W3C//DTD XHT ...
- k[原创]Faster R-CNN论文翻译
物体检测论文翻译系列: 建议从前往后看,这些论文之间具有明显的延续性和递进性. R-CNN SPP-net Fast R-CNN Faster R-CNN Faster R-CNN论文翻译 原文地 ...
- 2016.01.05 DOM笔记(一) 查找元素
DOM节点的种类 元素和标签是一个意思,例如<body>标签或者称为<body>元素 节点DOM的节点分为三类 元素节点,文本节点,属性节点 例如 <div id=‘b ...
- mongodb分片集群安装教程
mongodb 集群包含副本集群,主从集群以及分片集群,分片集群比较复杂,这里测试我采用了三台机器,交差部署 blog地址:http://www.cnblogs.com/caoguo 一 .环境:#m ...
- (Entity framework 应用篇)把权限判断封装在数据库访问层
这里,我只是以一个例子,说一下简单权限控制,通过这个例子,大家可以设计庞大的权限管理层,把权限控制封装到数据库访问层,这样程序员就不用再写权限判断的代码了 首先,先看看我数据库DBContext的定义 ...
- IntelliJ IDEA之windows下载安装、卸载
系统要求 系统支持:Microsoft Windows 8 / 7 / Vista / 2003 / XP(每个系统版本的 32 位和 64 位都可以) JDK 版本:Oracle JDK 1.6 或 ...
- 【转】关于JMeter线程组中线程数,Ramp-Up Period,循环次数之间的设置概念
关于JMeter线程组中线程数,Ramp-Up Period,循环次数之间的设置概念 笔者是个刚刚踏入压力测试领域不到2个月的小菜,这里分享一下线程组中3个参数之间关系的个人见解,不喜请!喷!,望大家 ...