eclipse / buildship

The Eclipse Plug-ins for Gradle project.
533 stars 169 forks source link

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

Open parthasaradhie opened 1 year ago

parthasaradhie commented 1 year ago

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: https://github.com/redhat-developer/vscode-java/issues/3176

parthasaradhie commented 1 year ago

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

camball commented 6 months ago

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.