我正在使用findbugs-maven-plugin
Maven生命周期的验证阶段。即它运行mvn clean install
。这是我父母pom.xml
(在一个多模块项目中)拥有的代码。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>findbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<findbugsXmlOutputDirectory>target/findbugs</findbugsXmlOutputDirectory>
<failOnError>false</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<configuration>
<transformationSets>
<transformationSet>
<dir>target/findbugs</dir>
<outputDir>target/findbugs</outputDir>
<stylesheet>plain.xsl</stylesheet>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
<targetExtension>.html</targetExtension>
</fileMapper>
</fileMappers>
</transformationSet>
</transformationSets>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</plugin>
这工作正常,并且在每个模块目标中都生成了html文件。但是,我想通过在maven构建过程中使用findbugs允许的参数来使这一步骤更进一步(例如onlyAnalyze
)。我不想在中添加配置pom.xml
。
我希望构建过程保持不变,除非我通过某些命令指定只分析一个类,例如通过运行以下命令:
mvn clean install -Dfindbugs:onlyAnalyze=MyClass
您知道我可以做到这一点的方法吗?
您可以通过这种方式调用独立目标:plugin-prefix:goal
或groupId:artifactId:version:goal
确保版本正确。在您的情况下:findbugs:findbugs
使用,-Dkey=value
您可以设置插件参数(如果已公开)。http://mojo.codehaus.org/findbugs-maven-plugin/findbugs-mojo.html没有显示该选项。只是比较一下:http : //mojo.codehaus.org/findbugs-maven-plugin/help-mojo.html确实有这样的选项。在这里它仍被称为Expression
with ${key}
,如今它的生成方式User property
与just相同key
。
如果只想从命令行设置Analyze,请要求mojo-team进行修复,或者执行以下操作:
<project>
<properties>
<findbugs.onlyAnalyze>false</findbugs.onlyAnalyze> <!-- default value -->
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<configuration>
<onlyAnalyze>${findbugs.onlyAnalyze}</onlyAnalyze>
</configuration>
</plugins>
</build>
</project>
现在你可以打电话 mvn findbugs:findbugs -Dfindbugs.onlyAnalyze=true
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句