So, each build.gradle looks like:
\nA module:
\nplugins {\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}\nB module:
\nplugins {\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}\nC module:
\nplugins {\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}\nWhen I run gradle build or gradle pmdMain
I got an issue:
\nExecution 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\nLet 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`
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...
Could you please help me in that question?
","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"Hi! A number of things to note here…
\nAs 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.
\nHowever, this error is not being triggered by the PMD analysis trying to load those classes!
\nThis 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"}}}-
|
Hello! Let me introduce my problem: I have a simple So, each build.gradle looks like: A module: B module: C module: When I run I got an issue: Let me highlight there is no any code used from module A in module B. Module Why does it work so? I thought PMD checks only transitive dependencies. I mean if there was some usage of class Could you please help me in that question? |
Beta Was this translation helpful? Give feedback.
-
|
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 analysis, however that doesn't stop Gradle from trying to ensure PMD has available "everything it may need" before it runs. |
Beta Was this translation helpful? Give feedback.
-
|
I think you should report this problem to the gradle team as they are maintaining the pmd plugin |
Beta Was this translation helpful? Give feedback.
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…