我有一个根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>packaging</groupId>
<artifactId>profiles</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<findbugsXmlOutput>true</findbugsXmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
<xmlOutput>true</xmlOutput>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>../common-core</module>
<module>../spark-monitoring-module</module>
<module>../mass-analytics-connector-module</module>
<!--<module>../global-aggregation-job</module>-->
<module>../location-aggregation-job</module>
<module>../bdr-aggregation-job</module>
<module>../activities-aggregation-job</module>
<module>../recovery-aggregation-job</module>
<module>../link-analysis-aggregation-job</module>
<module>../spark-streaming-module</module>
<module>../coordinates-to-mgrs-converter</module>
</modules>
</profile>
<profile>
<id>all</id>
<modules>
<module>../common-core</module>
<module>../spark-monitoring-module</module>
<module>../mass-analytics-connector-module</module>
<module>../global-aggregation-job</module>
<module>../location-aggregation-job</module>
<module>../bdr-aggregation-job</module>
<module>../activities-aggregation-job</module>
<module>../recovery-aggregation-job</module>
<module>../link-analysis-aggregation-job</module>
<module>../spark-streaming-module</module>
<module>../parquet-writer-sim</module>
<module>../coordinates-to-mgrs-converter</module>
</modules>
</profile>
<profile>
<id>act</id>
<modules>
<module>../common-core</module>
<module>../bdr-aggregation-job</module>
<module>../activities-aggregation-job</module>
</modules>
</profile>
</profiles>
当我在Jenkins中运行mvn clean install findbugs:findbugs时,它会创建每个模块的findbugsXml.xml,并因为profiles模块(不包含任何代码)而导致当前作业失败。我不希望finbugs插件在配置文件pom上运行(它是根pom),如何从findbugs插件中排除配置文件?
答案 0 :(得分:2)
真的有两个变化。
1)将您的插件部分(上面的构建)移动到pluginManagement部分,如下所示: 我已经更新了你的插件细节,因为它已经很老了。
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
<executions>
<execution>
<id>check</id>
<phase>package</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<xmlOutput>true</xmlOutput>
<xmlOutputDirectory>findbugsreports</xmlOutputDirectory>
<findbugsXmlOutput>true</findbugsXmlOutput>
<findbugsXmlOutputDirectory>target/site</findbugsXmlOutputDirectory>
<failOnError>false</failOnError>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> </plugin> </plugins> </build>
如果您需要更改一般属性,那么您可以在根pom中执行此操作,如果您需要在所涉及的单个子POM中更改特定属性。 这种方法的好处是,您可以在最高级别管理插件,并将它们包含在您认为适合儿童级别的位置。除非绝对必要,否则会削减多种配置。