1. build标签介绍
我们自己创建项目时,如果没用指定build标签,则会从超级POM继承build标签。当我们要定制构建过程的时候,可以参考超级POM和有效POM配置build标签覆盖默认值或补充配置
2. plugin标签详解
下面我们以maven-site-plugin为例进行讲解
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.0</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>C:\Users\dell\Desktop\maven-learn\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
<execution>
<id>default-deploy</id>
<phase>site-deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<outputDirectory>C:\Users\dell\Desktop\maven-learn\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
</executions>
<configuration>
<outputDirectory>C:\Users\dell\Desktop\maven-learn\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
execution 标签内:
- id:指定唯一标识
- phase:关联的生命周期阶段,在生命周期的哪个环节执行目标goal
- goals:goals标签中可以配置多个goal标签,但是一般只配置一个。当执行
mvn site:goal时,会在对应的生命周期phase,执行该goal在插件中绑定的MOJO - configuration:对插件目标的执行过程进行参数配置
maven-site-plugin插件的核心类是org.apache.maven.plugins.site.render.SiteMojo,它的父类是org.apache.maven.plugins.site.render.AbstractSiteRenderingMojo
每个插件的参数都不一样,具体需要看官方文档
3. 通过maven-compiler-plugin插件配置JDK版本
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<!-- 不同的插件的参数配置不一样 -->
<configuration>
<source>11</source>
<target>11</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
参数配置说明:
- source:指定java编译器-source参数的值。表示我们编写的源代码使用的jdk版本。作用和properties中指定的maven.compiler.source属性一样
- target:指定java编译器-target参数的值。表示将我们的源代码编译成哪个jdk版本的classes。作用和properties中指定的maven.compiler.target属性一样
1万+

被折叠的 条评论
为什么被折叠?



