Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error : Java is picking wrong version for dependency resolution for gradle projects #1244

Open
parthasaradhie opened this issue Jul 4, 2023 · 2 comments

Comments

@parthasaradhie
Copy link

Java is picking wrong version for dependency resolution, like
For the test cases the transitive "compile" dep take precedence than "testCompile"

Expected Behavior

For test cases testCompile dependencies should take precedence than transitive "compile" dependencies.

Current Behavior

For the test cases the transitive "compile" dep take precedence than "testCompile"

Context

I cant able to use VSCode java or eclipse to run my project but I can import and run in Intellij
This completely stops using eclipse or vscode for my gradle projects.

Steps to Reproduce

kindly check-out https://github.com/parthasaradhie/vscode-gradle-import-error-demo
try in eclipse, vscode
or Intellij you can see the difference

Your Environment

all the current latest versions of plugins in vscode
or latest eclipse

screen shot

Image 01-07-23 at 2 05 AM

if i chekout in intellij its working

image

I know i have the transitive junit 4.12 dep is coming from "compile" of powermock and junit dep of 4.13 is "testCompile" but it should work as the compiler should consider the 4.13 one

Kindly check for more details in downstream issue:
redhat-developer/vscode-java#3176

@parthasaradhie
Copy link
Author

Any update or Is there any patch to resolve this issue?

@camball
Copy link

camball commented Apr 19, 2024

I'm having the exact same issue—would love to know when an update is available.

Update: I was able to fix temporarily with help from here, ensuring repositories { mavenLocal() } was in my build.gradle, and the following was specified after:

configurations.all {
  resolutionStrategy {
    force 'group:name:version'
  }
}

Also had to make sure to run ./gradlew publishToMavenLocal as it was a local build that was not being loaded correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants