Maven插件配置继承

时间:2013-09-05 11:42:11

标签: java maven plugins pom.xml parent-pom

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

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

由于

1 个答案:

答案 0 :(得分:-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>

Child 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>