[Project combat] Maven plug-in configuration and introduction

1. What is the Maven plugin?

Maven plugins are tools used to extend the Maven build process.
Maven plugins can be used to accomplish various tasks such as compiling code, running tests, packaging applications, and more.

2. How to configure the Maven plugin?

Configure plugins in the pom.xml file, using the following syntax to configure plugins: to use them during the build process.

grammar

<build>
    <plugins>
        <plugin>
            <groupId>插件的groupId</groupId>
            <artifactId>插件的artifactId</artifactId>
            <version>插件的版本号</version>
            <configuration>
                <!-- 插件的配置选项 -->
            </configuration>
        </plugin>
    </plugins>
</build>

Below is an example:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

In this example, a plugin named maven-compiler-plugin is configured, which is used to compile Java code.
Specifies the source and object code versions, as well as some other configuration options.

3. Common Maven plugins

Maven plugin Maven plugin explained
maven-compiler-plugin Compile Java code
maven-surefire-plugin run unit tests
maven-failsafe-plugin run integration tests
maven-jar-plugin Packaging JAR files, packaging Java applications as JAR files
maven-war-plugin Packaging WAR files, packaging Java Web applications as WAR files
maven-ear-plugin Package the EAR file and package the compiled code into an EAR file
maven-source-plugin Package the source code into a JAR file
maven-rar-plugin Pack the compiled code into a RAR file
maven-shade-plugin Package an executable JAR file, packaging the project and its dependencies into a single JAR file
maven-install-plugin Install the project into the local warehouse, install the project into the local Maven warehouse
maven-deploy-plugin Deploy projects to remote warehouses, deploy projects to remote Maven warehouses
maven-clean-plugin Clean up the project directory, clean up the project's build directory
maven-remote-resources-plugin Copy resource files, copy resources from remote warehouse
maven-resources-plugin Copy resource files to output directory
maven-release-plugin Publish project version, automate release process
maven-assembly-plugin Package component distribution, package the project and its dependencies into a distributable archive
maven-antrun-plugin Execute Ant tasks
maven-ant-plugin Execute Ant tasks
maven-scm-publish-plugin Publish project changes to a source control system
maven-scm-plugin Integrate with source control systems
maven-versions-plugin Manage project versions
maven-changes-plugin Generate release notes
maven-archetype-plugin Generate project skeleton
maven-artifact-plugin Create and manipulate Maven artifacts
maven-embedder-plugin Embed Maven
maven-gpg-plugin Sign and verify Maven artifacts
maven-help-plugin Provides help with Maven commands
maven-indexer-plugin Generate Maven index
maven-invoker-plugin Execute the Maven project
maven-jlink-plugin Create a custom runtime image
maven-model-plugin Generate Java classes
maven-nar-plugin Package C/C++ code into Maven artifacts
maven-bundle-plugin Package the project as an OSGi bundle
maven-osgi-plugin Package the project as an OSGi bundle
maven-plugin-plugin Generate Maven plugin descriptor
maven-license-plugin Generate project license
maven-reactor-plugin Handle multi-module projects
maven-repository-plugin Generate Maven repository
maven-script-plugin execute script
maven-enforcer-plugin Enforce project constraints, enforce rules
maven-jdepend-plugin Analyze code dependencies
maven-dependency-plugin Manage project dependencies
maven-dependency-analyze-plugin Analyze project dependencies
maven-dependency-tree-plugin 显示项目依赖树
maven-external-dependency-plugin 处理外部依赖
maven-dependency-check-plugin 检查项目依赖的安全性
maven-linkcheck-plugin 检查链接是否有效
maven-checkstyle-plugin 检查代码风格、检查代码是否符合编码标准
maven-pmd-plugin 检查代码质量、分析代码是否存在潜在问题
maven-findbugs-plugin 检查代码缺陷、分析代码是否存在潜在的错误
maven-doap-plugin 生成DOAP文件
maven-idea-plugin 生成IntelliJ IDEA项目文件
maven-eclipse-plugin 生成Eclipse项目文件
maven-ejb-plugin 将编译后的代码打包成EJB文件
maven-file-management-plugin 处理文件
maven-jnlp-plugin 生成Java Web Start文件
maven-jarsigner-plugin 签名和验证JAR文件
maven-jmod-plugin 创建JMOD文件
maven-rpm-plugin 将编译后的代码打包成RPM文件
maven-pdf-plugin 生成PDF文档
maven-javadoc-plugin 生成Javadoc文档
maven-javadoc-plugin 生成Java文档
maven-site-plugin 生成项目文档、生成项目网站
maven-project-info-reports-plugin 生成项目信息报告
maven-cobertura-plugin 生成代码覆盖率报告
maven-jxr-plugin 生成代码交叉引用报告
maven-changelog-plugin 生成项目的变更日志
maven-jetty-plugin 启动Jetty服务器、将编译后的代码部署到Jetty服务器。
maven-jetty-maven-plugin 启动Jetty服务器
maven-jetty9-plugin 启动Jetty 9服务器
maven-jetty9-maven-plugin 启动Jetty 9服务器
maven-tomcat-plugin 启动Tomcat服务器
maven-tomcat-maven-plugin 启动Tomcat服务器
maven-tomcat7-plugin 启动Tomcat 7服务器
maven-tomcat7-maven-plugin 启动Tomcat 7服务器
maven-glassfish-plugin 启动Glassfish服务器
maven-glassfish-maven-plugin 启动Glassfish服务器
maven-glassfish3-plugin 启动Glassfish 3服务器
maven-glassfish3-maven-plugin 启动Glassfish 3服务器
maven-jboss-plugin 启动JBoss服务器、将编译后的代码部署到JBoss服务器。
maven-jboss-maven-plugin 启动JBoss服务器
maven-jboss7-plugin 启动JBoss 7服务器
maven-jboss7-maven-plugin 启动JBoss 7服务器
maven-jbossas-plugin 启动JBoss AS服务器
maven-jbossas-maven-plugin 启动JBoss AS服务器
maven-jbossas7-plugin 启动JBoss AS 7服务器
maven-jbossas7-maven-plugin 启动JBoss AS 7服务器

Guess you like

Origin blog.csdn.net/wstever/article/details/130286914