Maven从功能上说是个项目管理工具,但是从实现方式上说是个插件执行框架,因为任何项目管理的目标(goal)都是通过插件实现的。
一个Maven插件,至少应该包含如下信息:
例如,对于常用的Archetype插件,其对应的信息如下:
<groupId>org.apache.maven.plugins</groupId> <artifactId>maven-archetype-plugin</artifactId> <version>2.4</version>
从插件的功能上,Maven插件可以分为Build插件和Reporting插件。Build插件是在项目的build阶段执行的插件,往往在POM的<build>中配置。Reporting插件是在项目的site阶段执行的插件,往往在POM的<reporting>中配置。
Apache Maven项目本身就提供了大量的Maven插件,有核心插件、打包插件和通用工具插件等。
1. 核心插件
名称 |
类型 |
版本 |
发布日期 |
备注 |
clean |
Build |
3.0.0 |
2015-10-22 |
Clean up after the build. |
compiler |
Build |
3.5.1 |
2016-02-09 |
Compiles Java sources. |
deploy |
Build |
2.8.2 |
2014-08-27 |
Deploy the built artifact to the remote repository. |
failsafe |
Build |
2.19.1 |
2016-01-03 |
Run the JUnit integration tests in an isolated classloader. |
install |
Build |
2.5.2 |
2014-08-27 |
Install the built artifact into the local repository. |
resources |
Build |
2.7 |
2014-09-29 |
Copy the resources to the output directory for including in the JAR. |
site |
Build |
3.5.1 |
2016-04-15 |
Generate a site for the current project. |
surefire |
Build |
2.19.1 |
2016-01-03 |
Run the JUnit unit tests in an isolated classloader. |
verifier |
Build |
1.1 |
2015-04-14 |
Useful for integration tests - verifies the existence of certain conditions. |
2. 打包插件
名称 |
类型 |
版本 |
发布日期 |
备注 |
ear |
Build |
2.10.1 |
2015-06-27 |
Generate an EAR from the current project. |
ejb |
Build |
2.5.1 |
2015-06-20 |
Build an EJB (and optional client) from the current project. |
jar |
Build |
2.6 |
2015-03-09 |
Build a JAR from the current project. |
rar |
Build |
2.4 |
2014-09-08 |
Build a RAR from the current project. |
war |
Build |
2.6 |
2015-01-08 |
Build a WAR from the current project. |
app-client/acr |
Build |
3.0.0 |
2015-01-23 |
Build a JavaEE application client from the current project. |
shade |
Build |
2.4.3 |
2016-01-10 |
Build an Uber-JAR from the current project, including dependencies. |
source |
Build |
3.0.0 |
2016-02-10 |
Build a source-JAR from the current project. |
3. 报告插件
名称 |
类型 |
版本 |
发布日期 |
备注 |
changelog |
Reporting |
2.3 |
2014-06-24 |
Generate a list of recent changes from your SCM. |
changes |
Build+Reporting |
2.12 |
2016-03-31 |
Generate a report from an issue tracker or a change document. |
checkstyle |
Build+Reporting |
2.17 |
2015-10-15 |
Generate a Checkstyle report. |
doap |
Build |
1.2 |
2015-03-17 |
Generate a Description of a Project (DOAP) file from a POM. |
docck |
Build |
1.1 |
2015-04-03 |
Documentation checker plugin. |
javadoc |
Build+Reporting |
2.10.3 |
2015-04-14 |
Generate Javadoc for the project. |
jdeps |
Build |
3.0.0 |
2015-10-29 |
Run JDK's JDeps tool on the project. |
jxr |
Reporting |
2.5 |
2014-11-02 |
Generate a source cross reference. |
linkcheck |
Reporting |
1.2 |
2014-10-08 |
Generate a Linkcheck report of your project's documentation. |
pmd |
Build+Reporting |
3.6 |
2015-12-17 |
Generate a PMD report. |
project-info-reports |
Reporting |
2.9 |
2016-03-01 |
Generate standard project reports. |
surefire-report |
Reporting |
2.19.1 |
2016-01-03 |
Generate a report based on the results of unit tests. |
4. 其他工具插件
名称 |
类型 |
版本 |
发布日期 |
备注 |
ant |
Build |
2.4 |
2014-12-15 |
Generate an Ant build file for the project. |
antrun |
Build |
1.8 |
2014-12-26 |
Run a set of ant tasks from a phase of the build. |
archetype |
Build |
2.4 |
2015-08-09 |
Generate a skeleton project structure from an archetype. |
assembly |
Build |
2.6 |
2015-10-10 |
Build an assembly (distribution) of sources and/or binaries. |
dependency |
Build+Reporting |
2.10 |
2015-01-27 |
Dependency manipulation (copy, unpack) and analysis. |
enforcer |
Build |
1.4.1 |
2015-08-23 |
Environmental constraint checking (Maven Version, JDK etc), User Custom Rule Execution. |
gpg |
Build |
1.6 |
2015-01-19 |
Create signatures for the artifacts and poms. |
help |
Build |
2.2 |
2013-02-23 |
Get information about the working environment for the project. |
invoker |
Build+Reporting |
2.0.0 |
2015-06-27 |
Run a set of Maven projects and verify the output. |
jarsigner |
Build |
1.4 |
2015-01-21 |
Signs or verifies project artifacts. |
patch |
Build |
1.2 |
2015-03-09 |
Use the gnu patch tool to apply patch files to source code. |
|
Build |
1.3 |
2015-02-16 |
Generate a PDF version of your project's documentation. |
plugin |
Build+Reporting |
3.4 |
2015-01-04 |
Create a Maven plugin descriptor for any mojos found in the source tree, to include in the JAR. |
release |
Build |
2.5.3 |
2015-10-17 |
Release the current project - updating the POM and tagging in the SCM. |
remote-resources |
Build |
1.5 |
2013-08-14 |
Copy remote resources to the output directory for inclusion in the artifact. |
repository |
Build |
2.4 |
2015-02-22 |
Plugin to help with repository-based tasks. |
scm |
Build |
1.9.4 |
2015-04-01 |
Execute SCM commands for the current project. |
scm-publish |
Build |
1.1 |
2014-05-18 |
Publish your Maven website to a scm location. |
stage |
Build |
1.0 |
2015-03-03 |
Assists with release staging and promotion. |
toolchains |
Build |
1.1 |
2014-11-12 |
Allows to share configuration across plugins. |
补充:Apache Maven项目中已经过时不用的插件
名称 |
类型 |
版本 |
过时的时间 |
备注 |
eclipse |
Build |
2.10 |
2015-10-07 |
Generate an Eclipse project files for the current project. |
idea |
Build |
2.2.1 |
2013-07-26 |
Create/update an IDEA workspace for the current project (individual modules are created as IDEA modules) |
one |
Build |
1.3 |
2013-07-30 |
A plugin for interacting with legacy Maven 1.x repositories and builds. |
reactor |
Build |
1.1 |
2014-03-24 |
Build a subset of interdependent projects in a reactor (Maven 2 only). |
除了Apache Maven项目提供的Maven插件之外,其他组织或公司也可以开发并发布Maven插件,如Apache Tomcat项目提供的Apache Tomat插件等。
对于常用的Maven插件,我们将在后续的文章中陆续介绍。
参考文献:
http://maven.apache.org/plugins/index.html