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

最新文章

  1. 谈谈计算机上的那些存储器-Memory Hierarchy
  2. jsp网站服务器配置
  3. 用Log Parser Studio分析IIS日志
  4. 由多线程引起的map取值为null的分析
  5. C#中克隆随机数的三种方法(为什么我想到了茴字的四种写法
  6. [转]Form中控制Tab画布不同标签间切换的方法
  7. winform下mapxtreme2008 v7.0 生成release版提示找不到dll问题
  8. 四轴飞行器1.6 emwin与ucgui的移植,汉字外挂字库移植和DEMO效果对比
  9. Bandwidth内存带宽測试工具
  10. HDU多赛学校9 HDU4969 Just a Joke 【数学积分】
  11. 从Dynamics CRM2011到Dynamics CRM2016的升级之路
  12. 控制可编辑的Div 在添加图片,或者@某人的时候 光标移动到最后
  13. IntelliJ IDEA 2018 破解过程[详细步骤](Mac OS &amp; Windows)
  14. TJOI2011书架(dp)
  15. 洛谷P1886 滑动窗口(POJ.2823 Sliding Window)(区间最值)
  16. BZOJ 5281--[Usaco2018 Open]Talent Show(分数规划&amp;单调队列&amp;DP)
  17. 《Linux内核分析》第二周学习报告
  18. json数据在前端(javascript)和后端(php)转换
  19. R语言两种方式求指定日期所在月的天数
  20. LeetCode——Convert Sorted Array to Binary Search Tree

热门文章

  1. CSS-类和ID选择器的区别
  2. Android 使用 Application 简单介绍
  3. linux命令大杂烩之网络管理
  4. UNIX环境高级编程--6
  5. crontab的使用
  6. 增加删除div
  7. ajax 实现输入提示效果
  8. H5 标签属性、input属性
  9. postgresql用sql语句查询表结构
  10. cookie和sessionStorage 、localStorage 对比