Submodule dependency resolution from main module


(Gurpreet Malhi) #1

I have web and service two modules in my project. I am forcing a particular version of hibernate-core:5.2.4 in root build.gradle file, in web module I am using

compile project(':service')

In service module i am using spring boot (1.4.2) starter data jpa module and following block. By default spring-boot-data-jpa has hibernate-core:5.0.11.Final therefore, excluding it so that forced version of 5.2.4.Final can be found.

compile("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}") {
	exclude(module: 'spring-boot-starter-logging')
	exclude(group: 'org.hibernate', module: 'hibernate-core')
	exclude(group: 'org.hibernate', module: 'hibernate-entitymanager')
}

When i check service:dependencyInsight hibernate-core:5.2.4.Final is forced. But, when I check web:dependencyInsight hibernate-core:5.0.11.Final is used.

Even I do have fail on version conflict its not failing and not sure how 5.0.11.Final is being put on service compile dependency.

configurations.all {
resolutionStrategy {
    failOnVersionConflict()
}

Note sure from where 5.0.11,Final is being added and how to overcome it. Any help will be really appreciable.


(Stefan Oehme) #2

Each project has its own configuration. Changing the root project has no effect on the subprojects.

You can use an allProjects {} block in the root if you want to configure something in all projects.

Also if you force a version, an exclude is not necessary.


(Carlo Luib-Finetti) #3

you can call “gradle webmodule:dependencies” and you will see where Gradle finds this version in the web module.