1

给定:在build/plugins部分中具有某个插件配置的父 pom 。以上述 pom 为父母的孩子。

问题:孩子会继承讨论中插件的父配置吗?

谢谢

4

1 回答 1

-1

在某种程度上 - 是的 - 但我预计会有限制。

这是继承的一些用途的简化示例。这显示了项目属性和依赖项详细信息的重用。我相信还有其他例子。

父 POM:

<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.xxx</groupId>
  <artifactId>ArtefactID</artifactId>
  <version>1.2.3.4</version>
  <packaging>pom</packaging>

  <name>${project.artifactId} - ${project.version}</name>
  <modules>
    <module>AModule</module>
    <module>AnotherModule</module>
  </modules>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <!-- Re-use project details. -->
        <groupId>${project.groupId}</groupId>
        <artifactId>AModule</artifactId>
        <version>${project.version}</version>
        <scope>provided</scope>
      </dependency>
      <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>AnotherModule</artifactId>
        <version>${project.version}</version>
        <scope>provided</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>

子 POM:

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.xxx</groupId>
    <artifactId>ArtefactID</artifactId>
    <version>1.2.3.4</version>
  </parent>

  <!-- Inherits project version from parent POM -->
  <name>AModule - ${project.version}</name>
  <artifactId>AModule</artifactId>
  <packaging>jar</packaging>

  <dependencies>
   <dependency>
      <!-- Inherits version and scope from parent POM -->
      <groupId>${project.groupId}</groupId>
      <artifactId>ANotherModule</artifactId>
    </dependency>
  </dependencies>
</project>
于 2013-09-05T11:54:48.593 回答