1

I have a project that depends transitively on hibernate-core versions 5.2.x and 5.3.x. I would like to know where does 5.2.x comes from. Using the dependencies task I can only see libraries depend on 5.3.x.

Using dependencyInsight:

$ ./gradlew -q :mymodule:dependencyInsight --dependency hibernate-core --configuration compile
org.hibernate:hibernate-core:5.2.10.Final (selected by rule)
   variant "runtime"

org.hibernate:hibernate-core:5.3.7.Final -> 5.2.10.Final
   variant "runtime"
\--- org.springframework.boot:spring-boot-starter-data-jpa:2.1.0.RELEASE
     +--- project :core
     |    \--- compile
     \--- com.github.alturkovic.distributed-lock:distributed-lock- 
jdbc:1.2.2
          \--- project :core (*)

But both packages listed here depend on 5.3, not 5.2.

So how can I know where this version comes from?

EDIT: both modules dependencyInsight, without --configuration:

$ ./gradlew -q :moduleA:dependencyInsight --dependency hibernate-core                        
org.hibernate:hibernate-core:5.3.7.Final (selected by rule)
   variant "default+runtime" [
      Requested attributes not found in the selected variant:
         org.gradle.usage                   = java-api
         org.jetbrains.kotlin.platform.type = jvm
   ]
+--- compileClasspath
\--- org.springframework.boot:spring-boot-starter-data-jpa:2.1.0.RELEASE
     +--- project :core
     |    \--- compileClasspath
     \--- com.github.alturkovic.distributed-lock:distributed-lock-jdbc:1.2.2
          \--- project :core (*)

(*) - dependencies omitted (listed previously)

A web-based, searchable dependency report is available by adding the --scan option.
$ ./gradlew -q :moduleB:dependencyInsight --dependency hibernate-core 
org.hibernate:hibernate-core:5.3.7.Final
   variant "runtime" [
      Requested attributes not found in the selected variant:
         org.gradle.usage                   = java-api
         org.jetbrains.kotlin.platform.type = jvm
   ]
\--- org.springframework.boot:spring-boot-starter-data-jpa:2.1.0.RELEASE
     +--- compileClasspath
     \--- com.github.alturkovic.distributed-lock:distributed-lock-jdbc:1.2.2
          \--- compileClasspath

(*) - dependencies omitted (listed previously)

A web-based, searchable dependency report is available by adding the --scan option.
andrew
  • 3,879
  • 4
  • 25
  • 43
  • basically 'org.hibernate:hibernate-core:5.2.10.Final (selected by rule)' tells gradle somehow to ignore your listed dependency and force to 5.2.10.Final. Can you try to list the dependencies without the compile configuration? So the runtime and compile will be listed? It might be that this rule was added by a spring module like ' Spring dependency-management-plugin' Might be an helpfull answer here: https://stackoverflow.com/questions/37153484/why-does-gradle-downgrade-my-transitive-dependencies-in-a-grails-3-1-application – Nico Nov 29 '18 at 09:41
  • Hard to tell without your `build.gradle` file, though I'm guessing something with build variants judging by the first line of the output – Jeroen Steenbeeke Nov 29 '18 at 09:42
  • Possible duplicate of [Using gradle to find dependency tree](https://stackoverflow.com/questions/21645071/using-gradle-to-find-dependency-tree) – prophet1906 Nov 29 '18 at 09:47
  • @prophet1906 using dependencies task was the first thing I tried :D – andrew Nov 29 '18 at 09:51
  • @JeroenSteenbeeke not using build variants (aren't those just an Android thing?) – andrew Nov 29 '18 at 09:52
  • did you try project reports plugin? check build/reports/project/dependencies/index.html – prophet1906 Nov 29 '18 at 09:52
  • @andrew not sure if they're Android specific (I do primarily use Gradle with Android), but the build output mentions variants by name – Jeroen Steenbeeke Nov 29 '18 at 09:53
  • @prophet1906 tried project-report, still only shows org.hibernate:hibernate-core:5.3.7.Final ➡ 5.2.10.Final but never list a dependency depending on 5.2 explicitly – andrew Nov 29 '18 at 10:31

1 Answers1

1

This is kind of embarrassing.

In our gradle.properties we had:

hibernate.version=5.2.10.Final

and I wasn't aware of it. I discovered it randomly today.

andrew
  • 3,879
  • 4
  • 25
  • 43