Maven的完整性
项目管理功能的具体表现
下面是spring-boot-starter的POM文件, 可以看到: 除了我们熟悉的坐标标签, dependenices标签, 还有description, url, organization, licenses, developers, scm, issueManagement等这些描述项目信息的标签
description标签: 当前jar包的介绍
organization标签: 组织, 子标签name: 组织名, 子标签url: 官网地址
licenses标签: 类似于授权许可相应的, 子标签name: 许可名, 子标签url: 许可地址
developers标签: 开发对应标签, 子标签developer, 子标签name: 开发组织名, 子标签email: 开发组织邮箱, 子标签organization: ,子标签organizationUrl: 官网
scm标签: 软件配置管理, 子标签connection: 链接一般是git:git://, 子标签developerConnection: 开发链接一般是git:ssh, 子标签url: 链接一般是git:https仓库地址
issueManagement解决问题管理, 子标签system: 一般来说是github或者gitee这类型的种类, 子标签url: 对应的地址链接
code
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0modelVersion>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starterartifactId>
<version>2.5.6version>
<name>spring-boot-startername>
<description>Core starter, including auto-configuration support, logging and YAMLdescription>
<url>https://spring.io/projects/spring-booturl>
<organization>
<name>Pivotal Software, Inc.name>
<url>https://spring.iourl>
organization>
<licenses>
<license>
<name>Apache License, Version 2.0name>
<url>https://www.apache.org/licenses/LICENSE-2.0url>
license>
licenses>
<developers>
<developer>
<name>Pivotalname>
<email>info@pivotal.ioemail>
<organization>Pivotal Software, Inc.organization>
<organizationUrl>https://www.spring.ioorganizationUrl>
developer>
developers>
<scm>
<connection>scm:git:git://github.com/spring-projects/spring-boot.gitconnection>
<developerConnection>scm:git:ssh://git@github.com/spring-projects/spring-boot.gitdeveloperConnection>
<url>https://github.com/spring-projects/spring-booturl>
scm>
<issueManagement>
<system>GitHubsystem>
<url>https://github.com/spring-projects/spring-boot/issuesurl>
issueManagement>
<dependencies>
<dependency>
……
dependency>
dependencies>
project>
所以从「项目管理」的角度来看, Maven提供了如下这些功能:
项目对象(POM): 将整个项目本体抽象, 封装为应用成虚中的一个对象, 以便于管理和操作
全局性构建逻辑重用: Maven对整个构建过程进行分装之后, 程序只需要制定配置信息即可完成构建. 让构建过程从Ant的「编程式」升级到了Maven的「声明式」
构件的标准集合: 在Maven提供的标准框架体系内, 所有的构件都可以按照统一的规范生成和使用
构件关系定义: Maven定义了构件之间的三种基本关系, 让大型应用系统可以使用Maven来进行管理
插件目标系统: Maven核心程序定义抽象的生命周期, 然后将插件的目标绑定到生命周期中的特定阶段, 实现了标准和具体实现解耦合, 让Maven程序极具扩展性
项目描述信息的维护: 我们不仅可以在Pom中声明项目描述信息, 更可以将整个项目相关信息收集起来生成HTMl页面组成的一个可以直接访问的站点. 这些项目描述信息包括:
公司和组织信息
项目许可
开发成员信息
issue管理信息
SCM信息
…等
超级POM
官方解释
The Super POM is Maven’s default POM. All POMs extend the Super POM unless explicitly set, meaning the configuration specified in the Super POM is inherited by the POMs you created for your projects.
译文:Super POM 是 Maven 的默认 POM。除非明确设置,否则所有 POM 都扩展 Super POM,这意味着 Super POM 中指定的配置由您为项目创建的 POM 继承。
所以我们自己的POM即使没有明确指定一个父工程(副POM), 其实也默认继承了超级POM. 就好比一个Java类默认继承了Object类
那么超级POM中定义如下
<project>
<modelVersion>4.0.0modelVersion>
<repositories>
<repository>
<id>centralid>
<name>Central Repositoryname>
<url>https://repo.maven.apache.org/maven2url>
<layout>defaultlayout>
<snapshots>
<enabled>falseenabled>
snapshots>
repository>
repositories>
<pluginRepositories>
<pluginRepository>
<id>centralid>
<name>Central Repositoryname>
<url>https://repo.maven.apache.org/maven2url>
<layout>defaultlayout>
<snapshots>
<enabled>falseenabled>
snapshots>
<releases>
<updatePolicy>neverupdatePolicy>
releases>
pluginRepository>
pluginRepositories>
<build>
<directory>${project.basedir}/targetdirectory>
<outputDirectory>${project.build.directory}/classesoutputDirectory>
<finalName>${project.artifactId}-${project.version}finalName>
<testOutputDirectory>${project.build.directory}/test-classestestOutputDirectory>
<sourceDirectory>${project.basedir}/src/main/javasourceDirectory>
<scriptSourceDirectory>${project.basedir}/src/main/scriptsscriptSourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/javatestSourceDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/resourcesdirectory>
resource>
resources>
<testResources>
<testResource>
<directory>${project.basedir}/src/test/resourcesdirectory>
testResource>
testResources>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-pluginartifactId>
<version>1.3version>
plugin>
<plugin>
<artifactId>maven-assembly-pluginartifactId>
<version>2.2-beta-5version>
plugin>
<plugin>
<artifactId>maven-dependency-pluginartifactId>
<version>2.8version>
plugin>
<plugin>
<artifactId>maven-release-pluginartifactId>
<version>2.5.3version>
plugin>
plugins>
pluginManagement>
build>
<reporting>
<outputDirectory>${project.build.directory}/siteoutputDirectory>
reporting>
<profiles>
<profile>
<id>release-profileid>
<activation>
<property>
<name>performReleasename>
<value>truevalue>
property>
activation>
<build>
<plugins>
<plugin>
<inherited>trueinherited>
<artifactId>maven-source-pluginartifactId>
<executions>
<execution>
<id>attach-sourcesid>
<goals>
<goal>jar-no-forkgoal>
goals>
execution>
executions>
plugin>
<plugin>
<inherited>trueinherited>
<artifactId>maven-javadoc-pluginartifactId>
<executions>
<execution>
<id>attach-javadocsid>
<goals>
<goal>jargoal>
goals>
execution>
executions>
plugin>
<plugin>
<inherited>trueinherited>
<artifactId>maven-deploy-pluginartifactId>
<configuration>
<updateReleaseInfo>trueupdateReleaseInfo>
configuration>
plugin>
plugins>
build>
profile>
profiles>
project>
父POM
有效POM
概念
有效pom英文翻译为effective Pom, 他的概念是这样的–在POM继承关系中, 子POM可以覆盖父POM中的配置; 如果子POM没有覆盖, 那么父POM中的配置将会被继承. 按照这个规则, 继承管系中的所有POM叠加到一起, 就得到了一个最终生效的POM. 显然Maven世纪运行过程中, 执行构建操作就是按照这个最终生效的POM来运行的. 这个最终生效的POM就是有效POM,
查看有效POM命令
mvn help:effective-pom
/Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home/bin/java -Dvisualgc.id=56778845030875 -Dmaven.multiModuleProjectDirectory=/Users/zangzihe/Desktop/GitHub/test/test-maven-parent -Dmaven.home=/Users/zangzihe/Desktop/study/maven/apache-maven-3.6.3 -Dclassworlds.conf=/Users/zangzihe/Desktop/study/maven/apache-maven-3.6.3/bin/m2.conf -Dmaven.ext.class.path=/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven-event-listener.jar -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=60237:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Users/zangzihe/Desktop/study/maven/apache-maven-3.6.3/boot/plexus-classworlds.license:/Users/zangzihe/Desktop/study/maven/apache-maven-3.6.3/boot/plexus-classworlds-2.6.0.jar org.codehaus.classworlds.Launcher -Didea.version=2022.1.3 -s /Users/zangzihe/Desktop/study/maven/apache-maven-3.6.3/conf/settings_1.17.xml help:effective-pom
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] test-maven-parent [pom]
[INFO] test-maven-son [jar]
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-help-plugin/maven-metadata.xml
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-help-plugin/maven-metadata.xml (653 B at 609 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-help-plugin/3.2.0/maven-help-plugin-3.2.0.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-help-plugin/3.2.0/maven-help-plugin-3.2.0.pom (11 kB at 30 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-help-plugin/3.2.0/maven-help-plugin-3.2.0.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugins/maven-help-plugin/3.2.0/maven-help-plugin-3.2.0.jar (86 kB at 156 kB/s)
[INFO]
[INFO] --------------------< com.azang:test-maven-parent >---------------------
[INFO] Building test-maven-parent 1.0-SNAPSHOT [1/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.2.0:effective-pom (default-cli) @ test-maven-parent ---
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-model/3.6.1/maven-model-3.6.1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-model/3.6.1/maven-model-3.6.1.pom (4.0 kB at 11 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven/3.6.1/maven-3.6.1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven/3.6.1/maven-3.6.1.pom (24 kB at 55 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/3.2.0/plexus-utils-3.2.0.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/3.2.0/plexus-utils-3.2.0.pom (4.8 kB at 13 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugin-tools/maven-plugin-tools-generators/3.5.2/maven-plugin-tools-generators-3.5.2.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugin-tools/maven-plugin-tools-generators/3.5.2/maven-plugin-tools-generators-3.5.2.pom (4.2 kB at 9.5 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.5.2/maven-plugin-tools-api-3.5.2.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.5.2/maven-plugin-tools-api-3.5.2.pom (2.9 kB at 8.6 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/net/sf/jtidy/jtidy/r938/jtidy-r938.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/net/sf/jtidy/jtidy/r938/jtidy-r938.pom (9.2 kB at 27 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/shared/maven-artifact-transfer/0.10.0/maven-artifact-transfer-0.10.0.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/shared/maven-artifact-transfer/0.10.0/maven-artifact-transfer-0.10.0.pom (0 B at 0 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/1.4/plexus-utils-1.4.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/1.4/plexus-utils-1.4.pom (0 B at 0 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/com/thoughtworks/xstream/xstream/1.4.11.1/xstream-1.4.11.1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/com/thoughtworks/xstream/xstream/1.4.11.1/xstream-1.4.11.1.pom (20 kB at 53 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/com/thoughtworks/xstream/xstream-parent/1.4.11.1/xstream-parent-1.4.11.1.pom
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/com/thoughtworks/xstream/xstream-parent/1.4.11.1/xstream-parent-1.4.11.1.pom (37 kB at 74 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-model/3.6.1/maven-model-3.6.1.jar
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugin-tools/maven-plugin-tools-generators/3.5.2/maven-plugin-tools-generators-3.5.2.jar
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.5.2/maven-plugin-tools-api-3.5.2.jar
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/shared/maven-artifact-transfer/0.10.0/maven-artifact-transfer-0.10.0.jar
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/net/sf/jtidy/jtidy/r938/jtidy-r938.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/shared/maven-artifact-transfer/0.10.0/maven-artifact-transfer-0.10.0.jar (0 B at 0 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/shared/maven-common-artifact-filters/3.0.1/maven-common-artifact-filters-3.0.1.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/shared/maven-common-artifact-filters/3.0.1/maven-common-artifact-filters-3.0.1.jar (0 B at 0 B/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/3.2.0/plexus-utils-3.2.0.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-model/3.6.1/maven-model-3.6.1.jar (186 kB at 340 kB/s)
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/com/thoughtworks/xstream/xstream/1.4.11.1/xstream-1.4.11.1.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugin-tools/maven-plugin-tools-api/3.5.2/maven-plugin-tools-api-3.5.2.jar (24 kB at 36 kB/s)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/net/sf/jtidy/jtidy/r938/jtidy-r938.jar (250 kB at 320 kB/s)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/plugin-tools/maven-plugin-tools-generators/3.5.2/maven-plugin-tools-generators-3.5.2.jar (48 kB at 60 kB/s)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/3.2.0/plexus-utils-3.2.0.jar (263 kB at 273 kB/s)
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/com/thoughtworks/xstream/xstream/1.4.11.1/xstream-1.4.11.1.jar (621 kB at 594 kB/s)
[INFO]
Effective POMs, after inheritance, interpolation, and profiles are applied:
<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== -->
<!-- -->
<!-- Generated by Maven Help Plugin on 2022-07-12T22:46:25+08:00 -->
<!-- See: http://maven.apache.org/plugins/maven-help-plugin/ -->
<!-- -->
<!-- ====================================================================== -->
<projects>
<!-- ====================================================================== -->
<!-- -->
<!-- Effective POM for project -->
<!-- 'com.azang:test-maven-parent:pom:1.0-SNAPSHOT' -->
<!-- -->
<!-- ====================================================================== -->
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.azang</groupId>
<artifactId>test-maven-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>test-maven-parent</name>
<url>http://maven.apache.org</url>
<modules>
<module>test-maven-son</module>
</modules>
<properties>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
<maven.compiler.source>1.17</maven.compiler.source>
<maven.compiler.target>1.17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/src/main/java</sourceDirectory>
<scriptSourceDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/src/main/scripts</scriptSourceDirectory>
<testSourceDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/src/test/java</testSourceDirectory>
<outputDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/target/classes</outputDirectory>
<testOutputDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/target/test-classes</testOutputDirectory>
<resources>
<resource>
<directory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/src/test/resources</directory>
</testResource>
</testResources>
<directory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/target</directory>
<finalName>test-maven-parent-1.0-SNAPSHOT</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/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>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/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>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/target/site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/target/site</outputDirectory>
</reporting>
</project>
<!-- ====================================================================== -->
<!-- -->
<!-- Effective POM for project 'com.azang:test-maven-son:jar:1.0-SNAPSHOT' -->
<!-- -->
<!-- ====================================================================== -->
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.azang</groupId>
<artifactId>test-maven-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.azang</groupId>
<artifactId>test-maven-son</artifactId>
<version>1.0-SNAPSHOT</version>
<name>test-maven-son</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
<maven.compiler.source>1.17</maven.compiler.source>
<maven.compiler.target>1.17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/test-maven-son/src/main/java</sourceDirectory>
<scriptSourceDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/test-maven-son/src/main/scripts</scriptSourceDirectory>
<testSourceDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/test-maven-son/src/test/java</testSourceDirectory>
<outputDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/test-maven-son/target/classes</outputDirectory>
<testOutputDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/test-maven-son/target/test-classes</testOutputDirectory>
<resources>
<resource>
<directory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/test-maven-son/src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/test-maven-son/src/test/resources</directory>
</testResource>
</testResources>
<directory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/test-maven-son/target</directory>
<finalName>test-maven-son-1.0-SNAPSHOT</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>default-testResources</id>
<phase>process-test-resources</phase>
<goals>
<goal>testResources</goal>
</goals>
</execution>
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/test-maven-son/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>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/test-maven-son/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>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/test-maven-son/target/site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>/Users/zangzihe/Desktop/GitHub/test/test-maven-parent/test-maven-son/target/site</outputDirectory>
</reporting>
</project>
</projects>
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for test-maven-parent 1.0-SNAPSHOT:
[INFO]
[INFO] test-maven-parent .................................. SUCCESS [ 5.136 s]
[INFO] test-maven-son ..................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.462 s
[INFO] Finished at: 2022-07-12T22:46:26+08:00
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
小结
help插件的各个命令目标
官网说明地址
目标 | 说明 |
---|---|
help:active-profiles | 列出当前已激活的 profile |
help:all-profiles | 列出当前工程所有可用 profile |
help:describe | 描述一个插件和/或 Mojo 的属性 |
help:effective-pom | 以 XML 格式展示有效 POM |
help:effective-settings | 为当前工程以 XML 格式展示计算得到的 settings 配置 |
help:evaluate | 计算用户在交互模式下给出的 Maven 表达式 |
help:system | 显示平台详细信息列表,如系统属性和环境变量 |
使用help:evaluate查看属性值
使用命令
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] test-maven-parent [pom]
[INFO] test-maven-son [jar]
[INFO]
[INFO] --------------------< com.azang:test-maven-parent >---------------------
[INFO] Building test-maven-parent 1.0-SNAPSHOT [1/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-help-plugin:3.2.0:evaluate (default-cli) @ test-maven-parent ---
[INFO] No artifact parameter specified, using 'com.azang:test-maven-parent:pom:1.0-SNAPSHOT' as project.
[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
# 输入要查看的key[表达式]
${maven.compiler.source}
[INFO]
# 表达式计算结果
1.17
[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
# 使用0退出
0
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for test-maven-parent 1.0-SNAPSHOT:
[INFO]
[INFO] test-maven-parent .................................. SUCCESS [03:59 min]
[INFO] test-maven-son ..................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:59 min
[INFO] Finished at: 2022-07-15T11:52:51+08:00
[INFO] ------------------------------------------------------------------------
通过Maven访问系统属性
Java系统属性一览
code
public static void main(String[] args) {
Properties properties = System.getProperties();
Set