【发布时间】:2013-09-05 11:42:11
【问题描述】:
鉴于: 在 build/plugins 部分中具有插件特定配置的父 pom。 以上述 pom 为父母的孩子。
问题:孩子会继承讨论中的插件的父配置吗?
谢谢
【问题讨论】:
-
它用于我无法在我的电脑上检查的环境中 - 但我可以尝试引入一个虚拟插件'只是为了好玩':)
标签: java maven plugins pom.xml parent-pom
鉴于: 在 build/plugins 部分中具有插件特定配置的父 pom。 以上述 pom 为父母的孩子。
问题:孩子会继承讨论中的插件的父配置吗?
谢谢
【问题讨论】:
标签: java maven plugins pom.xml parent-pom
在一定程度上 - 是的 - 但我预计会有限制。
这里是继承的一些用途的简化示例。这显示了项目属性和依赖项详细信息的重用。我相信还有其他例子。
父 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>
【讨论】: