在父pom中定义的maven排除插件

use*_*201 24 maven

我有一个带有一些插件的父pom.在我的孩子pom中,我想排除一个插件.

我怎样才能做到这一点?

小智 9

我有类似的要求在孩子中运行一些插件但不是父POM.我通过<skip>true</skip> 在父母POM中陈述来实现这一点.

父pom条目在下面

<plugin>
        <groupId>eviware</groupId>
        <artifactId>maven-soapui-plugin</artifactId>
        <version>4.0.0</version>
        <inherited>false</inherited>
        <dependencies>
          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
          </dependency>
        </dependencies> 
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin> 
Run Code Online (Sandbox Code Playgroud)

儿童项目pom条目如下

<plugins>
        <plugin>
            <groupId>eviware</groupId>
            <artifactId>maven-soapui-plugin</artifactId>
            <version>4.0.0</version>
            <configuration>
                <settingsFile>site-service-web/src/test/soapui/soapui-settings.xml</settingsFile>
                <projectFile>site-service-web/src/test/soapui/PodifiSite-soapui-project.xml</projectFile>
                <outputFolder>site-service-web/target/surefire-reports</outputFolder>
                <junitReport>true</junitReport>
                <exportwAll>true</exportwAll>
                <printReport>true</printReport>
            </configuration>
        </plugin>
    </plugins>
Run Code Online (Sandbox Code Playgroud)

  • 当您将其放入子 pom 中时,`&lt;configuration&gt;&lt;skip&gt;true&lt;/skip&gt;&lt;/configuration&gt;` 也会起作用 (3认同)

小智 7

您可以在pluginManagement部分定义父pom中的所有插件

            <pluginManagement>
                <plugins>
                    ...
                     <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.8</version>
                        <executions>
                            <execution>
                                <id>unpack-dependencies</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>unpack-dependencies</goal>
                                </goals>
                                <configuration>
                                    <includeTypes>tar.bz2</includeTypes>
                                    <outputDirectory>${project.basedir}/target/dependencies</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                  ...
                </plugins>
            </pluginManagement>
Run Code Online (Sandbox Code Playgroud)

在父 poms 和子 poms 中之后,您可以控制该插件的执行阶段

    <plugins>
          <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
      </plugins>
Run Code Online (Sandbox Code Playgroud)

如果您将其粘贴到父 pom 中,请不要忘记 option <inherited>false</inherited>,它会禁用子 pom 中的执行继承。


Rag*_*ram 5

您可以在父pom中声明所有插件<pluginManagement>.在每个子节点中,您可以声明该子节点使用的插件.这样,您可以根据需要包含或排除插件.

您也可以查看此相关的SO讨论.

  • 这个答案并没有真正回答如何排除某些特定的继承插件的问题. (8认同)
  • 在我的情况下,我有一个插件,由10个子模块中的9个使用.我认为将插件放在父级中会更容易,让9个孩子继承并告诉第10个孩子要排除.我知道你在谈论的方式.只是想知道是否可以从子项目中排除插件....如果maven没有这种能力,那很好.我不知道maven在一起,所以发布在这里,以了解maven是否有这样的功能. (3认同)