2012-01-29

Working with Java 7 and Maven quality assurance plugins (Code coverage, Checkstyle, Findbugs and PMD) on Sonar

At present, only the default maven-findbugs-plugin will work on Java 7. But with a little tweaking, we can get all the rest of the widely used maven quality assurance(QA) plugins working!

The only open source and free code coverage tool working on Java 7, is named JaCoCo.

In the pom file below, i have set all the QA plugins to the maven phase "pre-site" and will work with Sonar.
To run all the maven QA plugins at ones, use the command:
mvn clean install pre-site

So how do we put this all together:


 4.0.0

 
  1.7
  UTF-8
  ${sourceEncoding}
  ${sourceEncoding}

  jacoco
  reuseReports
 

 
  
   
    
     org.codehaus.sonar
     sonar-maven-plugin
     2.0
     
      true
     
    
   
  

  
   
    org.apache.maven.plugins
    maven-compiler-plugin
    2.3.2
    
     ${jdk.version}
     ${jdk.version}
    
   

   
    org.apache.maven.plugins
    maven-jxr-plugin
    2.3
    
     
      pre-site
      
       jxr
      
     
    
   
   
    org.apache.maven.plugins
    maven-pmd-plugin
    2.6
    
     ${jdk.version}
     true
     ${project.reporting.outputDirectory}/xref
    
    
     
      pre-site
      
       pmd
       cpd
      
     
    
    
     
      pmd
      pmd
      4.3
     
    
   
   
    org.apache.maven.plugins
    maven-checkstyle-plugin
    2.8
    
     true
     ${project.reporting.outputDirectory}/xref
    
    
     
      pre-site
      
       checkstyle
      
     
    
    
     
      com.puppycrawl.tools
      checkstyle
      5.5
      
       
        com.sun
        tools
       
      
     
    
   
   
    org.codehaus.mojo
    findbugs-maven-plugin
    2.4.0
    
     true
     Max
    
    
     
      pre-site
      
       findbugs
      
     
    
   
   
    org.jacoco
    jacoco-maven-plugin
    0.5.6.201201232323
    
     
      jacoco-initialize
      initialize
      
       prepare-agent
      
     
     
      jacoco-site
      pre-site
      
       report
      
     
    
   
  
 


0 reacties:

Post a Comment