Analyzing JSP Code

The PMD plugin analyzes Java by default. You can configure it to analyze Java Server Pages files instead as shown below.

The example assumes that the JSP source code is stored in various subdirectories under the source directory src/main/webapp and enables the built-in JSP ruleset (basic).

Note that you have to make sure that the build-helper-maven-plugin is executed, so that the additional source directory is actually added. To generate the site report, you can include e.g. the generate-sources phase:

mvn generate-sources site

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.7</version>
        <configuration>
          <sources>
            <source>${basedir}/src/main/webapp</source>
          </sources>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>add-source</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>3.6</version>
        <configuration>
          <language>jsp</language>
          <rulesets>
            <ruleset>jsp-basic</ruleset>
          </rulesets>
          <includes>
            <include>**/*.jsp</include>
          </includes>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
  ...
</project>