2016-11-28 262 views
0

我的目标是在maven项目上执行findbugs - >生成xml - >将xml转换为html &如果有高优先级的FindBugs警告,最终会失败生成。下面是pom.xml的插件配置的配置我已经配置maven pom.xml中的Findbugs插件配置

<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> 

我的问题是,HTML转换没有发生,说明

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

能否pom.xml的正确性进行验证&也有人帮助我为什么HTML转换不会发生的原因?

回答

0

上述插件配置的问题是在验证阶段而不是安装阶段配置了失败高位。因此,如果验证阶段出现构建错误,则不会生成输出xml,因为找不到输出xml。这是通过更改它来安装固定

<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>