在maven中从parent-pom运行child-中的插件

问题描述 投票:0回答:1

我想创建一个父pom,超过100个子pom将使用它,并且我希望每个孩子只使用

maven install
运行父插件,但不幸的是它不会在子插件中运行父插件。

这是我的父pom,我的2个checkstyle和spotbugs插件都在里面

  <build>
<pluginManagement>

  <plugins>

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-checkstyle-plugin</artifactId>
      <version>${maven.checkstyle.plugin}</version>

      <dependencies>
        <dependency>
          <groupId>com.puppycrawl.tools</groupId>
          <artifactId>checkstyle</artifactId>
          <version>${maven.puppycrawl.version}</version>
        </dependency>
      </dependencies>

      <configuration>
        <consoleOutput>true</consoleOutput>
        <failsOnError>true</failsOnError>
        <linkXRef>false</linkXRef>
        <violationSeverity>warning</violationSeverity>
      </configuration>

      <executions>
        <execution>
          <id>validate</id>
          <goals>
            <goal>check</goal>
          </goals>
          <phase>validate</phase>
        </execution>
      </executions>

    </plugin>

    <plugin>
      <groupId>com.github.spotbugs</groupId>
      <artifactId>spotbugs-maven-plugin</artifactId>
      <version>${spotbugs.plugin.version}</version>
      <configuration>
        <threshold>Low</threshold>
        <xmlOutput>true</xmlOutput>
      </configuration>

      <executions>
        <execution>
          <goals>
            <goal>check</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>

</pluginManagement>

这是我孩子的 pom 中

  <parent>
<groupId>org.parent</groupId>
<artifactId>parent_name</artifactId>
<version>0.0.1</version>
</parent>

现在我想使用

mvn install
mvn clean install
来运行子 pom 并运行这两个插件,而不需要在每个子 pom 中重写它们,但它不会运行插件。

谁能告诉我我该怎么办?

java maven plugins pom.xml spotbugs
1个回答
0
投票

/pluginManagement/plugins 中删除并将其放入 /plugins 中。 /pluginManagement & /dependencyManagement 仅用于定义配置,实际使用时需要使用 /plugins & /dependency 调用。

© www.soinside.com 2019 - 2024. All rights reserved.