Xellos
Xellos

Reputation: 87

Gradle Dependency resolution changes from 4.10.3 to 6.1.1

I am currently attempting to upgrade my projects gradle version from 4.10.3 to 6.1.1. The problem I am facing, and am unable to wrap my head around, is a change to the dependency resolution. I do not see any remarks to that in the migration guides.

Specifically what seems to happen, is that some (or all) transitives are getting ignored now. Here is the setup in a simplified form:

I have project Main and library Boot. Main has a dependency on Boot which looks like this:

implementation group: 'com.example', name: 'boot', version: '1.0'

Boot has a dependency on the servlet-api

implementation group: 'javax.servlet', name: 'servlet-api', version: '2.5'

This is one of plenty examples. In 4.10.3 it is no problem for Main to reference the ServletContext. Now it works in my IDE, but the gradlew compileJava task fails saying ServletContext is a unknown symbol.

Similar but not exactly the same, I am unable to pass the dependencies from a different sourceSet. Here the second example: I have project Service and library Commons. Project Service has an additional source set called api. Now Service contains following dependencies

apiImplementation group: "com.example", name: "commons", version: "1.0"

implementaiton sourceSets.api.output

With 4.10.3 this works perfectly fine, but with 6.1.1 I am unable to use elements from commons in Service:main. Here too I have plenty of cases, where it fails.

Usually I would assume that I have forgotten something, and I spent quite some time already scouring the web for clues, but seeing how it works perfectly fine with 4.10.3, but fails with 6.1.1 (no other changes) it must be a change in the dependency resolution, or a change in the syntax. Either way I am unable to find any documentation on the particular subject. My hope is that someone has encountered this issue already, and found a solution to it.

Upvotes: 1

Views: 111

Answers (1)

madhead
madhead

Reputation: 33392

Your main module cannot use servlet classes because of API and implementation separation:

The api configuration should be used to declare dependencies which are exported by the library API, whereas the implementation configuration should be used to declare dependencies which are internal to the component.

You are using implementation configuration and so it's dependecies are not exposed transitively.

Try changing the scope of servlet dependency to api, or include servlet dependency into the main module.

Upvotes: 1

Related Questions