Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/pmdPublic

PMD fails withCould not find org.springframework.boot:spring-boot-starter-web#5666

Answeredbyjsotuyod
Disteonne asked this question inQ&A
Discussion options

Hello!

Let me introduce my problem:

I have a simplemix project. I mean I have the project with the next structure:

root|\ A (spring-based with java)\ B (It takes A)\ C (It takes B)...

So, each build.gradle looks like:

A module:

plugins {    id 'java-library'    id 'org.springframework.boot' version '3.4.4'    id 'io.spring.dependency-management' version '1.1.7'}group = 'org.example'version = '0.0.1-SNAPSHOT'java {    toolchain {        languageVersion = JavaLanguageVersion.of(21)    }}repositories {    mavenCentral()}dependencies {    implementation 'org.springframework.boot:spring-boot-starter-web'}

B module:

plugins {    id 'java'    id 'pmd'}pmd {    consoleOutput = true    toolVersion = "7.12.0"}group = 'org.example'version = '1.0-SNAPSHOT'repositories {    mavenCentral()}dependencies {    implementation project(':A')}

C module:

plugins {    id 'java'    id 'org.springframework.boot' version '3.4.4'    id 'io.spring.dependency-management' version '1.1.7'}group = 'org.example'version = '0.0.1-SNAPSHOT'java {    toolchain {        languageVersion = JavaLanguageVersion.of(21)    }}repositories {    mavenCentral()}dependencies {    implementation 'org.springframework.boot:spring-boot-starter-web'    implementation project(':B')}tasks.named('test') {    useJUnitPlatform()}

When I rungradle build orgradle pmdMain

I got an issue:

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

Let me highlightthere is no any code used from module A in module B. ModuleB just takesA withimplementation project(':A') and nothing more: threre is no any import, or class, just declaration inbuild.gradle`

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

Could you please help me in that question?

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 wholeruntime 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 thatwhen 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

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 wholeruntime 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 thatwhen 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.

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

Hello! Thank you so much for your answer
But does it mean I have to declare spring dependency in B module anyway? Maybe you are aware of it.

Maybe there is a way to exclude spring-boot from class path of ‘pmdMain’ task but I am not sure it’s good practice for that resolution

My concern is that this module B was supposed to be simple java module and I am really confused by this issue because of that

@jsotuyod
Comment options

To be honest, I don't know why this is failing. If project A can resolve the dependency from maven central, B should be able to do so too transitively (ie: to produce a fat jar)… but I don't know what those spring gradle plugins may be doing under the hood…

Answer selected byDisteonne
Comment options

I think you should report this problem to the gradle team as they are maintaining the pmd plugin

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

[8]ページ先頭

©2009-2025 Movatter.jp