I have a big maven project that uses the pmd plugin for code quality checks.
since I started using the pmd plugin i get the following warning message:
You should add the maven-jxr-plugin and run the jxr:jxr
goal before the site
lifecycle if the maven-jxr-plugin
is added as a plugin like in your case:
clean jxr:jxr site
Otherwise you should add it as a report if you want it to work with mvn site
. Take a look at the JXR Usage Documentation :
JXR Usage
Mind there is also the ability to disable the xref feature by adding
<configuration>
<linkXRef>false</linkXRef>
</configuration>
to the maven-pmd-plugin plugin. This resolves the warning without making the build even longer due to running an additional reporting plugin. E.g. if you run your builds in Jenkins, the Jenkins PMD plugin can take care of relating PMD warnings to source code, there is no need to run another Maven plugin for this.
You should add the maven-jxr-plugin
to the reportingPlugin
section.
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>
Re run it and enjoy.
BTW, maybe you'll need to run once the jxr:jxr
goal to first generate some file that will be used by pmd.
It is way easier to configure it this way and not tie it to the site phase.
Then, it is as simple as mvn test
.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
</dependencies>
<configuration>
<testSourceDirectory>src/test/java</testSourceDirectory>
<includes>
<include>com.whatever.suite.*</include>
</includes>
<systemPropertyVariables>
<selenide.remote>${grid.hub}</selenide.remote>
</systemPropertyVariables>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<outputDirectory>target/surefire-reports</outputDirectory>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>during-tests</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>