Imran khan
Imran khan

Reputation: 847

How to generate PMD report in Maven multi-module Project?

I am new to configuration for all the code-analysis tool link PMD,CheckStyle,Sonar. I have multi-module maven project.I created separate sub-module for code-analysis.I want to run PMD on my all sub-module and to achieve as html report. project requirement is to keep separate code for code analysis.

Project Structure.

project-parent
 |
 |-sub-module1
 |   |-pom.xml(sub-module1 pom)
 |-sub-moduel2
 |   |-pom.xml (sub-moduel2 pom)
 |-code-analysis
 |   |-pom.xml (Using this pom i want to generate report for PMD)
 |
 |-pom.xml (parent pom)

I just started pom.xml ( under code-analysis )

pom.xml

 <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>
  <parent>
    <groupId>com.spring.web</groupId>
    <artifactId>project-parent</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </parent>
  <artifactId>code-analysis</artifactId>
  <name>code-analysis</name>



  <properties>
      <maven.pmd.plugin.version>3.4</maven.pmd.plugin.version>
      <maven.jxr.version>2.3</maven.jxr.version>
      <maven.javadoc.plugin>2.8.1</maven.javadoc.plugin>

      <main.basedir>${project.parent.basedir}</main.basedir>

      <maven.checkstyle.plugin>2.7</maven.checkstyle.plugin>

      <maven.jxr.plugin>2.3</maven.jxr.plugin>
      <maven.pmd.plugin>2.7.1</maven.pmd.plugin>
      <maven.sonar.plugin>3.2-RC3</maven.sonar.plugin>
      <maven.surefire.plugin>2.12</maven.surefire.plugin>
      <maven.taglist.plugin>2.4</maven.taglist.plugin>

      <maven.versions.plugin>1.3.1</maven.versions.plugin>

      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>


  </properties>

     <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>${maven.jxr.version}</version>
            </plugin>
        </plugins>
    </reporting>


  <build>


  <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>${maven.pmd.plugin.version}</version>
      </plugin>


       <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${maven.javadoc.plugin}</version>
        <configuration><aggregate>true</aggregate>
        </configuration>
       </plugin>

   </plugins>

  </build>
 </project>

Upvotes: 1

Views: 2289

Answers (2)

Billy Liu
Billy Liu

Reputation: 126

Use the <aggregate>true</aggregate> settings of the plugin.

More configurations, please see http://maven.apache.org/plugins/maven-pmd-plugin/pmd-mojo.html

Upvotes: 1

Daniel Holmes
Daniel Holmes

Reputation: 402

Use the <format>html</format> setting of the plugin.

maven-pmd-plugin

Upvotes: 0

Related Questions