Skip to content
\n

So, each build.gradle looks like:

\n

A module:

\n
plugins {\n    id 'java-library'\n    id 'org.springframework.boot' version '3.4.4'\n    id 'io.spring.dependency-management' version '1.1.7'\n}\n\ngroup = 'org.example'\nversion = '0.0.1-SNAPSHOT'\n\njava {\n    toolchain {\n        languageVersion = JavaLanguageVersion.of(21)\n    }\n}\n\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation 'org.springframework.boot:spring-boot-starter-web'\n}\n
\n

B module:

\n
plugins {\n    id 'java'\n    id 'pmd'\n}\n\npmd {\n    consoleOutput = true\n    toolVersion = \"7.12.0\"\n}\n\ngroup = 'org.example'\nversion = '1.0-SNAPSHOT'\n\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation project(':A')\n}\n
\n

C module:

\n
plugins {\n    id 'java'\n    id 'org.springframework.boot' version '3.4.4'\n    id 'io.spring.dependency-management' version '1.1.7'\n}\n\ngroup = 'org.example'\nversion = '0.0.1-SNAPSHOT'\n\njava {\n    toolchain {\n        languageVersion = JavaLanguageVersion.of(21)\n    }\n}\n\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation 'org.springframework.boot:spring-boot-starter-web'\n    implementation project(':B')\n}\n\ntasks.named('test') {\n    useJUnitPlatform()\n}\n
\n

When I run gradle build or gradle pmdMain

\n

I got an issue:

\n
Execution failed for task ':B:pmdMain'.\n> Could not resolve all files for configuration ':B:mainPmdAuxClasspath'.\n   > Could not find org.springframework.boot:spring-boot-starter-web:.\n     Required by:\n         project :B > project :A\n\nPossible solution:\n - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html\n\n
\n

Let me highlight there is no any code used from module A in module B. Module B just takes A with implementation project(':A') and nothing more: threre is no any import, or class, just declaration in build.gradle`

\n

Why does it work so? I thought PMD checks only transitive dependencies. I mean if there was some usage of class TestController with @RestController spring aanotation from module A in module B then it's okay, but here...

\n

Could you please help me in that question?

","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"

Hi! A number of things to note here…

\n

As you would expect, PMD's analysis itself will only load classes as they are needed / referenced. In order to do so, PMD needs to be run with references to the whole runtime classpath. It even looks at the JRE.

\n

However, this error is not being triggered by the PMD analysis trying to load those classes!

\n

This is Gradle failing to resolve a gradle configuration for a task that is part of the Grade binary itself. At this point in Gradle's execution PMD has not yet even been initialized. This is intended to ensure that when PMD is actually run, the whole runtime classpath is available. If your code doesn't use a class PMD will not try to load it during analysis, however that doesn't stop Gradle from trying to ensure PMD has available \"everything it may need\" before it runs.

","upvoteCount":1,"url":"https://github.com/pmd/pmd/discussions/5666#discussioncomment-12730141"}}}
Discussion options

You must be logged in to vote

Hi! A number of things to note here…

As you would expect, PMD's analysis itself will only load classes as they are needed / referenced. In order to do so, PMD needs to be run with references to the whole runtime classpath. It even looks at the JRE.

However, this error is not being triggered by the PMD analysis trying to load those classes!

This is Gradle failing to resolve a gradle configuration for a task that is part of the Grade binary itself. At this point in Gradle's execution PMD has not yet even been initialized. This is intended to ensure that when PMD is actually run, the whole runtime classpath is available. If your code doesn't use a class PMD will not try to load it during ana…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@Disteonne
Comment options

@jsotuyod
Comment options

Answer selected by Disteonne
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants