子pom中未继承的java额外插件
我知道超级pom和继承的概念。但我仍然看到额外的插件神奇地出现在我的孩子模块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.practice</groupId>
<artifactId>learning-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>child-module1</module>
</modules>
<properties>
<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>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>fr.jcgay.maven.plugins</groupId>
<artifactId>buildplan-maven-plugin</artifactId>
<version>1.3</version>
</plugin>
</plugins>
</build>
</project>
子模块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>
<parent>
<groupId>com.practice</groupId>
<artifactId>learning-maven</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>child-module1</artifactId>
<version>1.0-SNAPSHOT</version>
</project>
如果我生成子模块和父模块的有效POM,我会得到: (为了便于阅读,我通过buildplan-maven-plugin展示了插件和目标的有效POM数据。我也检查了这些插件数据与有效POM的关系。)
[INFO] ------------------------------------------------------------------------
[INFO] Building learning-maven 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- buildplan-maven-plugin:1.3:list (default-cli) @ learning-maven ---
[INFO] Build Plan for learning-maven:
----------------------------------------------------------
PLUGIN | PHASE | ID | GOAL
----------------------------------------------------------
maven-install-plugin | install | default-install | install
maven-deploy-plugin | deploy | default-deploy | deploy
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building child-module1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- buildplan-maven-plugin:1.3:list (default-cli) @ child-module1 ---
[INFO] Build Plan for child-module1:
---------------------------------------------------------------------------------------
PLUGIN | PHASE | ID | GOAL
---------------------------------------------------------------------------------------
maven-resources-plugin | process-resources | default-resources | resources
maven-compiler-plugin | compile | default-compile | compile
maven-resources-plugin | process-test-resources | default-testResources | testResources
maven-compiler-plugin | test-compile | default-testCompile | testCompile
maven-surefire-plugin | test | default-test | test
maven-jar-plugin | package | default-jar | jar
maven-install-plugin | install | default-install | install
maven-deploy-plugin | deploy | default-deploy | deploy
[INFO] ------------------------------------------------------------------------
如果你在子模块中看到,你会得到比父模块更多的插件。 如果你想看超级POM,它是here。 那么,这些额外的插件从何而来呢
共 (0) 个答案