TheBlank
TheBlank

Reputation: 137

No Warnings are getting generated for maven-pmd-plugins

I am using maven-pmd-plugin, I have added this plugin in my parent pom, I have added some unused variable in my code but still it is not able to throw any warnings, everytime it is creating an empty report. Please let me know, If I am doing anything wrong.

<modules>
<module>src/dummy1/jni</module>
<module>src/dummy2/jni</module>
</modules>
<properties>
  <maven.deploy.skip>true</maven.deploy.skip>
  <maven.compiler.source>1.8</maven.compiler.source>
  <maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-pmd-plugin</artifactId>
      <version>3.17.0</version>
      <configuration>
        <linkXRef>true</linkXRef>
        <targetJdk>1.8</targetJdk>
        <skipEmptyReport>false</skipEmptyReport>
        <outputDirectory>${project.basedir}/../../../../out/</outputDirectory>
        <xrefLocation>${project.basedir}/../../../../out/</xrefLocation>
     </configuration>
    <executions>
      <execution>
        <goals>
          <goal>pmd</goal>
        </goals>
        <phase>validate</phase>
      </execution>
    </executions>
  </plugin>
</plugins>

Upvotes: 1

Views: 304

Answers (1)

Yan Khonski
Yan Khonski

Reputation: 13103

I also faced problems with PMD. I created a started project (java-17, maven, pmd, unit tests, log4j2).

https://github.com/yan-khonski-it/java-17-pmd

I used phase validate and goal check.

<executions>
  <execution>
    <id>check pmd and fail</id>
    <phase>validate</phase>
    <goals>
      <goal>check</goal>
    </goals>
  </execution>
</executions>

If you use goal PMD, PMD will still run, but its results are not in the console, but in target/pmd.xml (if you configure maven plugin properly). However, in this case the build passes.

Upvotes: 1

Related Questions