Aggregate findbugs report in Maven 3.0.5 -


i using multi-module maven project ( more 10 modules ). trying create findbugs report of module in single html page. there way?

for creating individual report each module, using below

<plugin>     <groupid>org.codehaus.mojo</groupid>     <artifactid>findbugs-maven-plugin</artifactid>     <version>3.0.0</version>     <configuration>         <!--             enables analysis takes more memory finds more bugs.             if run out of memory, changes value of effort element             'low'.         -->         <effort>max</effort>         <!-- build doesn't fail if problems found -->         <failonerror>false</failonerror>         <!-- reports bugs (other values medium , max) -->         <threshold>low</threshold>         <!-- produces xml report -->         <xmloutput>false</xmloutput>         <skip>${skipfindbugs}</skip>         <!-- configures directory in xml report created -->         <findbugsxmloutputdirectory>${project.build.directory}/findbugs</findbugsxmloutputdirectory>     </configuration>     <executions>         <!--             ensures findbugs inspects source code when project compiled.         -->         <execution>              <phase>compile</phase>             <goals>                 <goal>findbugs</goal>             </goals>         </execution>     </executions> </plugin>  <plugin>     <groupid>org.codehaus.mojo</groupid>     <artifactid>xml-maven-plugin</artifactid>     <version>1.0</version>     <configuration>         <transformationsets>             <transformationset>                 <!-- configures source directory of xml files. -->                 <dir>${project.build.directory}/findbugs</dir>                 <!-- configures directory in findbugs report written.-->                 <outputdir>${project.build.directory}/findbugs</outputdir>                 <!-- selects used stylesheet. -->                 <!-- <stylesheet>fancy-hist.xsl</stylesheet> -->                 <stylesheet>${project.parent.basedir}/default.xsl</stylesheet>                 <!--<stylesheet>plain.xsl</stylesheet>-->                 <!--<stylesheet>fancy.xsl</stylesheet>-->                 <!--<stylesheet>summary.xsl</stylesheet>-->                 <filemappers>                     <!-- configures file extension of output files. -->                     <filemapper implementation="org.codehaus.plexus.components.io.filemappers.fileextensionmapper">                         <targetextension>.html</targetextension>                     </filemapper>                 </filemappers>             </transformationset>         </transformationsets>     </configuration>     <executions>         <!-- ensures xslt transformation run when project compiled. -->         <execution>              <phase>compile</phase>             <goals>                 <goal>transform</goal>             </goals>         </execution>     </executions>     <dependencies>         <dependency>             <groupid>com.google.code.findbugs</groupid>             <artifactid>findbugs</artifactid>             <version>3.0.0</version>         </dependency>     </dependencies> </plugin> 

according official documentation of plugin (question n. 1), not possible.

however, here approach used achieve it:

  • add additional module existing multimodule project. additional module used reporting
  • configure buildhelper maven plugin dynamically add source code of other modules reporting module. note: can same resources, if required.
  • configure findbugs plugin on reporting module
  • add other modules dependencies of reporting module, in order have maven reactor build build @ end.
  • if required: don't want reporting module part of default build, create profile in aggregator/parent module redefines modules element , add reporting module it. such, when profile activated (i.e. via command line, on demand) reporting module added , aggregated report created.

as example, in aggregator/parent module can define following:

<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>com.sample</groupid>     <artifactid>findbugs-parent</artifactid>     <version>0.0.1-snapshot</version>     <packaging>pom</packaging>      <modules>         <module>findbugs-module1</module>         <module>findbugs-module2</module>     </modules>      <profiles>         <profile>             <id>findbugs-reporting</id>             <modules>                 <module>findbugs-module1</module>                 <module>findbugs-module2</module>                 <module>findbugs-reporting</module>             </modules>         </profile>     </profiles> </project> 

note: findbugs-reporting module added in findbugs-reporting profile. default, build ignore it.

in findbugs-reporting module, configure pom using configuration posted (findbugs , xml maven plugin) , add following:

<plugin>     <groupid>org.codehaus.mojo</groupid>     <artifactid>build-helper-maven-plugin</artifactid>     <version>1.9.1</version>     <executions>         <execution>             <id>add-source</id>             <phase>generate-sources</phase>             <goals>                 <goal>add-source</goal>             </goals>             <configuration>                 <sources>                     <source>..\findbugs-module1\src\main\java</source>                     <source>..\findbugs-module2\src\main\java</source>                 </sources>             </configuration>         </execution>     </executions> </plugin> 

note added sources other modules (change according project).

furthermore, need add dependencies reporting module. has depend on other modules in order built @ end (and such make sure take latest changes/sources other modules). example:

<dependencies>     <dependency>         <groupid>com.sample</groupid>         <artifactid>findbugs-module1</artifactid>         <version>0.0.1-snapshot</version>     </dependency>     <dependency>         <groupid>com.sample</groupid>         <artifactid>findbugs-module2</artifactid>         <version>0.0.1-snapshot</version>     </dependency> </dependencies> 

finally, can invoke reporting build following aggregator/parent dir:

mvn clean install -pfindbugs-reporting 

as such, build whole project , additionally activate reporting module, dynamically include sources other modules (as configured) , generate aggregated report.

depending on needs, can avoid profile step (if want part of default build) or activate profile default (so can skip reporting build deactivate via -p!findbugs-reporting) or use skipfindbugs property configured (and without profile, in such case).


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -