本文共 4884 字,大约阅读时间需要 16 分钟。
Maven从功能上说是个项目管理工具,但是从实现方式上说是个插件执行框架,因为任何项目管理的目标(goal)都是通过插件实现的。
一个Maven插件,至少应该包含如下信息:
例如,对于常用的Archetype插件,其对应的信息如下:
从插件的发布方式上,Maven插件可以分为 核心插件和 扩展插件。核心插件是Maven项目提供的、随着Maven发布包一起发布的插件,即提供了Maven内置的功能,如Maven内置的生命周期阶段事实上就是由Maven的若干个核心插件提供。扩展插件是对Maven的核心插件的补充,需要在POM中特别声明。org.apache.maven.plugins maven-archetype-plugin 2.4
从插件的功能上,Maven插件可以分为Build插件和Reporting插件。Build插件是在项目的build阶段执行的插件,往往在POM的<build>中配置。Reporting插件是在项目的site阶段执行的插件,往往在POM的<reporting>中配置。
Apache Maven项目本身就提供了大量的Maven插件,有核心插件、打包插件和通用工具插件等。
1. 核心插件
名称 | 类型 | 版本 | 发布日期 | 备注 |
| Build | 3.0.0 | 2015-10-22 | Clean up after the build. |
| Build | 3.5.1 | 2016-02-09 | Compiles Java sources. |
| Build | 2.8.2 | 2014-08-27 | Deploy the built artifact to the remote repository. |
| Build | 2.19.1 | 2016-01-03 | Run the JUnit integration tests in an isolated classloader. |
| Build | 2.5.2 | 2014-08-27 | Install the built artifact into the local repository. |
| Build | 2.7 | 2014-09-29 | Copy the resources to the output directory for including in the JAR. |
| Build | 3.5.1 | 2016-04-15 | Generate a site for the current project. |
| Build | 2.19.1 | 2016-01-03 | Run the JUnit unit tests in an isolated classloader. |
| Build | 1.1 | 2015-04-14 | Useful for integration tests - verifies the existence of certain conditions. |
2. 打包插件
名称 | 类型 | 版本 | 发布日期 | 备注 |
| Build | 2.10.1 | 2015-06-27 | Generate an EAR from the current project. |
| Build | 2.5.1 | 2015-06-20 | Build an EJB (and optional client) from the current project. |
| Build | 2.6 | 2015-03-09 | Build a JAR from the current project. |
| Build | 2.4 | 2014-09-08 | Build a RAR from the current project. |
| Build | 2.6 | 2015-01-08 | Build a WAR from the current project. |
| Build | 3.0.0 | 2015-01-23 | Build a JavaEE application client from the current project. |
| Build | 2.4.3 | 2016-01-10 | Build an Uber-JAR from the current project, including dependencies. |
| Build | 3.0.0 | 2016-02-10 | Build a source-JAR from the current project. |
3. 报告插件
名称 | 类型 | 版本 | 发布日期 | 备注 |
| Reporting | 2.3 | 2014-06-24 | Generate a list of recent changes from your SCM. |
| Build+Reporting | 2.12 | 2016-03-31 | Generate a report from an issue tracker or a change document. |
| Build+Reporting | 2.17 | 2015-10-15 | Generate a Checkstyle report. |
| Build | 1.2 | 2015-03-17 | Generate a Description of a Project (DOAP) file from a POM. |
| Build | 1.1 | 2015-04-03 | Documentation checker plugin. |
c | Build+Reporting | 2.10.3 | 2015-04-14 | Generate Javadoc for the project. |
| Build | 3.0.0 | 2015-10-29 | Run JDK's JDeps tool on the project. |
| Reporting | 2.5 | 2014-11-02 | Generate a source cross reference. |
| Reporting | 1.2 | 2014-10-08 | Generate a Linkcheck report of your project's documentation. |
| Build+Reporting | 3.6 | 2015-12-17 | Generate a PMD report. |
| Reporting | 2.9 | 2016-03-01 | Generate standard project reports. |
| Reporting | 2.19.1 | 2016-01-03 | Generate a report based on the results of unit tests. |
4. 其他工具插件
名称 | 类型 | 版本 | 发布日期 | 备注 |
| Build | 2.4 | 2014-12-15 | Generate an Ant build file for the project. |
| Build | 1.8 | 2014-12-26 | Run a set of ant tasks from a phase of the build. |
| Build | 2.4 | 2015-08-09 | Generate a skeleton project structure from an archetype. |
| Build | 2.6 | 2015-10-10 | Build an assembly (distribution) of sources and/or binaries. |
| Build+Reporting | 2.10 | 2015-01-27 | Dependency manipulation (copy, unpack) and analysis. |
| Build | 1.4.1 | 2015-08-23 | Environmental constraint checking (Maven Version, JDK etc), User Custom Rule Execution. |
| Build | 1.6 | 2015-01-19 | Create signatures for the artifacts and poms. |
| Build | 2.2 | 2013-02-23 | Get information about the working environment for the project. |
| Build+Reporting | 2.0.0 | 2015-06-27 | Run a set of Maven projects and verify the output. |
| Build | 1.4 | 2015-01-21 | Signs or verifies project artifacts. |
| 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. |
| 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. |
| Build | 2.5.3 | 2015-10-17 | Release the current project - updating the POM and tagging in the SCM. |
| Build | 1.5 | 2013-08-14 | Copy remote resources to the output directory for inclusion in the artifact. |
| Build | 2.4 | 2015-02-22 | Plugin to help with repository-based tasks. |
| Build | 1.9.4 | 2015-04-01 | Execute SCM commands for the current project. |
| Build | 1.1 | 2014-05-18 | Publish your Maven website to a scm location. |
| Build | 1.0 | 2015-03-03 | Assists with release staging and promotion. |
| Build | 1.1 | 2014-11-12 | Allows to share configuration across plugins. |
补充:Apache Maven项目中已经过时不用的插件
名称 | 类型 | 版本 | 过时的时间 | 备注 |
Build | 2.10 | 2015-10-07 | Generate an Eclipse project files for the current project. | |
Build | 2.2.1 | 2013-07-26 | Create/update an IDEA workspace for the current project (individual modules are created as IDEA modules) | |
Build | 1.3 | 2013-07-30 | A plugin for interacting with legacy Maven 1.x repositories and builds. | |
| 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://pjlai.baihongyu.com/