Maven POM元素解析

发布于:2024-04-15 ⋅ 阅读:(91) ⋅ 点赞:(0)

这是对Maven中使用的Maven项目描述符的引用。

<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"
  child.project.url.inherit.append.path=.. >
  <modelVersion/>
 
  <parent>
    <groupId/>
    <artifactId/>
    <version/>
    <relativePath/>
  </parent>
 
  <groupId/>
  <artifactId/>
  <version/>
  <packaging/>
 
  <name/>
  <description/>
  <url/>
  <inceptionYear/>
  <organization>
    <name/>
    <url/>
  </organization>
  <licenses>
    <license>
      <name/>
      <url/>
      <distribution/>
      <comments/>
    </license>
  </licenses>
 
  <developers>
    <developer>
      <id/>
      <name/>
      <email/>
      <url/>
      <organization/>
      <organizationUrl/>
      <roles/>
      <timezone/>
      <properties>
        <key>value</key>
      </properties>
    </developer>
  </developers>
  <contributors>
    <contributor>
      <name/>
      <email/>
      <url/>
      <organization/>
      <organizationUrl/>
      <roles/>
      <timezone/>
      <properties>
        <key>value</key>
      </properties>
    </contributor>
  </contributors>
 
  <mailingLists>
    <mailingList>
      <name/>
      <subscribe/>
      <unsubscribe/>
      <post/>
      <archive/>
      <otherArchives/>
    </mailingList>
  </mailingLists>
 
  <prerequisites>
    <maven/>
  </prerequisites>
 
  <modules/>
 
  <scm child.scm.connection.inherit.append.path=.. child.scm.developerConnection.inherit.append.path=.. child.scm.url.inherit.append.path=.. >
    <connection/>
    <developerConnection/>
    <tag/>
    <url/>
  </scm>
  <issueManagement>
    <system/>
    <url/>
  </issueManagement>
  <ciManagement>
    <system/>
    <url/>
    <notifiers>
      <notifier>
        <type/>
        <sendOnError/>
        <sendOnFailure/>
        <sendOnSuccess/>
        <sendOnWarning/>
        <address/>
        <configuration>
          <key>value</key>
        </configuration>
      </notifier>
    </notifiers>
  </ciManagement>
 
  <distributionManagement>
    <repository>
      <uniqueVersion/>
      <releases>
        <enabled/>
        <updatePolicy/>
        <checksumPolicy/>
      </releases>
      <snapshots>
        <enabled/>
        <updatePolicy/>
        <checksumPolicy/>
      </snapshots>
      <id/>
      <name/>
      <url/>
      <layout/>
    </repository>
    <snapshotRepository>
      <uniqueVersion/>
      <releases>
        <enabled/>
        <updatePolicy/>
        <checksumPolicy/>
      </releases>
      <snapshots>
        <enabled/>
        <updatePolicy/>
        <checksumPolicy/>
      </snapshots>
      <id/>
      <name/>
      <url/>
      <layout/>
    </snapshotRepository>
    <site child.site.url.inherit.append.path=.. >
      <id/>
      <name/>
      <url/>
    </site>
    <downloadUrl/>
    <relocation>
      <groupId/>
      <artifactId/>
      <version/>
      <message/>
    </relocation>
    <status/>
  </distributionManagement>
 
  <properties>
    <key>value</key>
  </properties>
 
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId/>
        <artifactId/>
        <version/>
        <type/>
        <classifier/>
        <scope/>
        <systemPath/>
        <exclusions>
          <exclusion>
            <groupId/>
            <artifactId/>
          </exclusion>
        </exclusions>
        <optional/>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId/>
      <artifactId/>
      <version/>
      <type/>
      <classifier/>
      <scope/>
      <systemPath/>
      <exclusions>
        <exclusion>
          <groupId/>
          <artifactId/>
        </exclusion>
      </exclusions>
      <optional/>
    </dependency>
  </dependencies>
 
  <repositories>
    <repository>
      <releases>
        <enabled/>
        <updatePolicy/>
        <checksumPolicy/>
      </releases>
      <snapshots>
        <enabled/>
        <updatePolicy/>
        <checksumPolicy/>
      </snapshots>
      <id/>
      <name/>
      <url/>
      <layout/>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <enabled/>
        <updatePolicy/>
        <checksumPolicy/>
      </releases>
      <snapshots>
        <enabled/>
        <updatePolicy/>
        <checksumPolicy/>
      </snapshots>
      <id/>
      <name/>
      <url/>
      <layout/>
    </pluginRepository>
  </pluginRepositories>
 
  <build>
    <sourceDirectory/>
    <scriptSourceDirectory/>
    <testSourceDirectory/>
    <outputDirectory/>
    <testOutputDirectory/>
    <extensions>
      <extension>
        <groupId/>
        <artifactId/>
        <version/>
      </extension>
    </extensions>
    <defaultGoal/>
    <resources>
      <resource>
        <targetPath/>
        <filtering/>
        <directory/>
        <includes/>
        <excludes/>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <targetPath/>
        <filtering/>
        <directory/>
        <includes/>
        <excludes/>
      </testResource>
    </testResources>
    <directory/>
    <finalName/>
    <filters/>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId/>
          <artifactId/>
          <version/>
          <extensions/>
          <executions>
            <execution>
              <id/>
              <phase/>
              <goals/>
              <inherited/>
              <configuration/>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId/>
              <artifactId/>
              <version/>
              <type/>
              <classifier/>
              <scope/>
              <systemPath/>
              <exclusions>
                <exclusion>
                  <groupId/>
                  <artifactId/>
                </exclusion>
              </exclusions>
              <optional/>
            </dependency>
          </dependencies>
          <goals/>
          <inherited/>
          <configuration/>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId/>
        <artifactId/>
        <version/>
        <extensions/>
        <executions>
          <execution>
            <id/>
            <phase/>
            <goals/>
            <inherited/>
            <configuration/>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId/>
            <artifactId/>
            <version/>
            <type/>
            <classifier/>
            <scope/>
            <systemPath/>
            <exclusions>
              <exclusion>
                <groupId/>
                <artifactId/>
              </exclusion>
            </exclusions>
            <optional/>
          </dependency>
        </dependencies>
        <goals/>
        <inherited/>
        <configuration/>
      </plugin>
    </plugins>
  </build>
 
  <reports/>
  <reporting>
    <excludeDefaults/>
    <outputDirectory/>
    <plugins>
      <plugin>
        <groupId/>
        <artifactId/>
        <version/>
        <reportSets>
          <reportSet>
            <id/>
            <reports/>
            <inherited/>
            <configuration/>
          </reportSet>
        </reportSets>
        <inherited/>
        <configuration/>
      </plugin>
    </plugins>
  </reporting>
 
  <profiles>
    <profile>
      <id/>
      <activation>
        <activeByDefault/>
        <jdk/>
        <os>
          <name/>
          <family/>
          <arch/>
          <version/>
        </os>
        <property>
          <name/>
          <value/>
        </property>
        <file>
          <missing/>
          <exists/>
        </file>
      </activation>
      <build>
        <defaultGoal/>
        <resources>
          <resource>
            <targetPath/>
            <filtering/>
            <directory/>
            <includes/>
            <excludes/>
          </resource>
        </resources>
        <testResources>
          <testResource>
            <targetPath/>
            <filtering/>
            <directory/>
            <includes/>
            <excludes/>
          </testResource>
        </testResources>
        <directory/>
        <finalName/>
        <filters/>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId/>
              <artifactId/>
              <version/>
              <extensions/>
              <executions>
                <execution>
                  <id/>
                  <phase/>
                  <goals/>
                  <inherited/>
                  <configuration/>
                </execution>
              </executions>
              <dependencies>
                <dependency>
                  <groupId/>
                  <artifactId/>
                  <version/>
                  <type/>
                  <classifier/>
                  <scope/>
                  <systemPath/>
                  <exclusions>
                    <exclusion>
                      <groupId/>
                      <artifactId/>
                    </exclusion>
                  </exclusions>
                  <optional/>
                </dependency>
              </dependencies>
              <goals/>
              <inherited/>
              <configuration/>
            </plugin>
          </plugins>
        </pluginManagement>
        <plugins>
          <plugin>
            <groupId/>
            <artifactId/>
            <version/>
            <extensions/>
            <executions>
              <execution>
                <id/>
                <phase/>
                <goals/>
                <inherited/>
                <configuration/>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId/>
                <artifactId/>
                <version/>
                <type/>
                <classifier/>
                <scope/>
                <systemPath/>
                <exclusions>
                  <exclusion>
                    <groupId/>
                    <artifactId/>
                  </exclusion>
                </exclusions>
                <optional/>
              </dependency>
            </dependencies>
            <goals/>
            <inherited/>
            <configuration/>
          </plugin>
        </plugins>
      </build>
 
      <modules/>
 
      <distributionManagement>
        <repository>
          <uniqueVersion/>
          <releases>
            <enabled/>
            <updatePolicy/>
            <checksumPolicy/>
          </releases>
          <snapshots>
            <enabled/>
            <updatePolicy/>
            <checksumPolicy/>
          </snapshots>
          <id/>
          <name/>
          <url/>
          <layout/>
        </repository>
        <snapshotRepository>
          <uniqueVersion/>
          <releases>
            <enabled/>
            <updatePolicy/>
            <checksumPolicy/>
          </releases>
          <snapshots>
            <enabled/>
            <updatePolicy/>
            <checksumPolicy/>
          </snapshots>
          <id/>
          <name/>
          <url/>
          <layout/>
        </snapshotRepository>
        <site child.site.url.inherit.append.path=.. >
          <id/>
          <name/>
          <url/>
        </site>
        <downloadUrl/>
        <relocation>
          <groupId/>
          <artifactId/>
          <version/>
          <message/>
        </relocation>
        <status/>
      </distributionManagement>
 
      <properties>
        <key>value</key>
      </properties>
 
      <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId/>
            <artifactId/>
            <version/>
            <type/>
            <classifier/>
            <scope/>
            <systemPath/>
            <exclusions>
              <exclusion>
                <groupId/>
                <artifactId/>
              </exclusion>
            </exclusions>
            <optional/>
          </dependency>
        </dependencies>
      </dependencyManagement>
      <dependencies>
        <dependency>
          <groupId/>
          <artifactId/>
          <version/>
          <type/>
          <classifier/>
          <scope/>
          <systemPath/>
          <exclusions>
            <exclusion>
              <groupId/>
              <artifactId/>
            </exclusion>
          </exclusions>
          <optional/>
        </dependency>
      </dependencies>
 
      <repositories>
        <repository>
          <releases>
            <enabled/>
            <updatePolicy/>
            <checksumPolicy/>
          </releases>
          <snapshots>
            <enabled/>
            <updatePolicy/>
            <checksumPolicy/>
          </snapshots>
          <id/>
          <name/>
          <url/>
          <layout/>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <releases>
            <enabled/>
            <updatePolicy/>
            <checksumPolicy/>
          </releases>
          <snapshots>
            <enabled/>
            <updatePolicy/>
            <checksumPolicy/>
          </snapshots>
          <id/>
          <name/>
          <url/>
          <layout/>
        </pluginRepository>
      </pluginRepositories>
 
      <reports/>
      <reporting>
        <excludeDefaults/>
        <outputDirectory/>
        <plugins>
          <plugin>
            <groupId/>
            <artifactId/>
            <version/>
            <reportSets>
              <reportSet>
                <id/>
                <reports/>
                <inherited/>
                <configuration/>
              </reportSet>
            </reportSets>
            <inherited/>
            <configuration/>
          </plugin>
        </plugins>
      </reporting>
    </profile>
  </profiles>
</project>

project

<project>元素是描述符的根。下表列出了所有可能的子元素。

Attribute Type Description
child.project.url.inherit.append.path String 当子级继承项目的url时,是否追加路径?注意:虽然出于技术原因,该字段的类型为String,但语义类型实际上是Boolean
Default value istrue
Since: Maven 3.6.1
Element Type Description
modelVersion String 指定了当前Maven模型的版本号
Parent Parent 父项目的位置(如果存在)。如果未指定父项目中的值,则它们将是此项目的默认值。该位置以group ID, artifact ID and version的形式给出。
groupId String 项目的通用唯一标识符。通常使用完全限定的包名称来将其与具有类似名称的其他项目(例如org.apache.maven)区分开来。
artifactId String groupId给定的组中是唯一的。artifact是由项目生产或使用的东西。Maven为项目生成的工件的示例包括:JAR、源代码和二进制发行版以及WAR。
version String 此项目生成的artifact的当前版本。
packaging String 该项目产生的工件的类型,例如jar war ear pom。插件可以创建自己的打包,因此也可以创建它们自己的打包类型,因此该列表不包含所有可能的类型。

Default value isjar

.
name String 项目名称
description String 项目的详细描述,Maven在需要描述项目时使用,例如在网站上。虽然可以将该元素指定为CDATA以允许在描述中使用HTML标记,但不建议允许纯文本表示。如果需要修改生成的网站的索引页,则可以指定自己的索引页而不是调整此文本。
url String 项目主页的URL。
默认值为:父值[+路径调整]+(artifactId或project.directory属性),或者如果项目的子级为.project.url.inherit.append.path=“false”,则仅为父值
inceptionYear String 项目开始的年份,用4位数字指定。此值在生成版权声明以及作为信息时使用。
Organization Organization 该元素描述项目所属组织的各种属性。创建文档时使用这些属性(用于版权声明和链接)。
licenses/license* List<License> (Many) 此元素描述此项目的所有许可证。每个许可都由许可元素描述,然后由其他元素描述。项目应仅列出应用于项目的许可证,而不是应用于依赖项的许可证。如果列出了多个许可证,则假设用户可以选择其中的任何一个,而不是必须全部接受。
developers/developer* List<Developer> (Many) 描述项目的提交者。
contributors/contributor* List<Contributor> (Many) 描述尚未提交的项目参与者。
mailingLists/mailingList* List<MailingList> (Many) Contains information about a project's mailing lists.
Prerequisites Prerequisites Describes the prerequisites in the build environment for this project.
modules/module* List<String> (Many) 要作为此项目的一部分生成的模块(有时称为子项目)。列出的每个模块都是包含该模块的目录的相对路径。为了与从父级计算默认url的方式一致,建议模块名称与artifact ids匹配。
Scm Scm Specification for the SCM used by the project, such as CVS, Subversion, etc.
IssueManagement IssueManagement The project's issue management system information.
CiManagement CiManagement The project's continuous integration information.
DistributionManagement DistributionManagement 支持将站点和工件分别部署到远程web服务器和存储库的项目的分发信息。
properties/key=value* Properties (Many) 可以在整个POM中用作替代的属性,并在启用时用作资源中的筛选器。格式为<name>value</name>。
DependencyManagement DependencyManagement 从该项目继承的项目的默认依赖项信息。此部分中的依赖项不会立即解析。相反,当从该POM派生的POM声明由匹配的groupId和artifactId描述的依赖项时,如果尚未指定该部分中的版本和其他值,则将其用于该依赖项。
dependencies/Dependency* List<Dependency> (Many) 

该元素描述与项目关联的所有依赖项。这些依赖项用于在构建过程中为项目构建类路径。它们将从该项目中定义的存储库中自动下载。有关详细信息,请参阅依赖关系机制。

repositories/Repository* List<Repository> (Many) The lists of the remote repositories for discovering dependencies and extensions.
pluginRepositories/pluginRepository* List<Repository> (Many) The lists of the remote repositories for discovering plugins for builds and reports.
Build Build Information required to build the project.
reports DOM Deprecated. Now ignored by Maven.
reporting Reporting 该元素包括用于在Maven生成的站点上生成报告的报告插件的规范。这些报告将在用户执行mvn站点时运行。所有报告都将包含在导航栏中以供浏览。
profiles/profile* List<Profile> (Many) 激活时将修改生成过程的项目本地生成配置文件的列表。

网站公告

今日签到

点亮在社区的每一天
去签到