简体   繁体   English

Maven pom.xml中的Findbugs插件配置

[英]Findbugs plugin configuration in maven pom.xml

My goal is to execute findbugs on a maven project -> generate xml -> convert xml to html & finally fail build if there are HIGH priority FindBugs warnings. 我的目标是在Maven项目上执行findbugs->生成xml->将xml转换为html,如果存在高优先级的FindBugs警告,则最终构建失败。 Below is the plugin configuration configuration in pom.xml I have configured 以下是我已配置的pom.xml中的插件配置配置

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>3.0.3</version>
                <executions>
                    <execution>
                        <id>noFailOnError</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <failOnError>false</failOnError>
                            <xmlOutput>true</xmlOutput>
                            <findbugsXmlOutputDirectory>${project.build.directory}/findbugs</findbugsXmlOutputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </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>${project.build.directory}/findbugs</dir>
                            <outputDir>${project.build.directory}/findbugs</outputDir>
                            <stylesheet>fancy-hist.xsl</stylesheet>
                            <!--<stylesheet>default.xsl</stylesheet> -->
                            <!--<stylesheet>plain.xsl</stylesheet> -->
                            <!--<stylesheet>fancy.xsl</stylesheet> -->
                            <!--<stylesheet>summary.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>


            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>3.0.3</version>
                <executions>
                    <execution>
                        <id>failing-on-high</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>findbugs</goal>
                        </goals>
                        <configuration>
                            <failOnError>true</failOnError>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

My problem is that html transformation is not happening stating that 我的问题是html转换并未发生,

[WARNING] No files found for transformation by stylesheet fancy-hist.xsl

Can the pom.xml correctness be verified & also can someone help me with the reason on why html tansformation is not happening ? 是否可以验证pom.xml的正确性,并且有人可以帮助我解决为什么html变形未发生的原因?

The issue with the above plugin configuration is that failing-on-high is configured during the verify phase rather than install phase. 上面的插件配置的问题是,在验证阶段而不是在安装阶段配置了高级别失败。 So in case of build error in verify phase, no output xml is generated because of which the output xml was not found. 因此,在验证阶段出现构建错误的情况下,不会生成任何输出xml,因此找不到该输出xml。 This was fixed by changing it to install 通过将其更改为安装进行修复

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>3.0.3</version>
                <executions>
                    <execution>
                        <id>failing-on-high</id>
                        <phase>install</phase>
                        <goals>
                            <goal>findbugs</goal>
                        </goals>
                        <configuration>
                            <failOnError>true</failOnError>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM