In order to use Type resolution during the analysis, PMD has to have access to the classpath of the project.

In case of a maven build, a file containing the classpath can be generated with: mvn dependency:build-classpath -Dmdep.outputFile=cp.txt Alternatively it is also possible include this in your pom.xml so it is generated as part of the build. See https://maven.apache.org/plugins/maven-dependency-plugin/usage.html for more information.

When using gradle, a file containing the classpath can be generated by adding task removecp(type: Delete) { delete "cp.txt" } subprojects { task printcp { new File(rootDir, "cp.txt").append(":" + sourceSets.main.runtimeClasspath.join(':')) } } to the end of your build.gradle and executing gradlew removecp printcp.