D. Silvest
D. Silvest

Reputation: 127

How to use implementation dependency from dependency in dependent Gradle project?

Recently one of the libraries in my project was released and one of changes was migration of buildscript to Gradle 6. So compile became implementation and so on. This means that I cannot access previously defined dependency because gradle does not use when compiling my project:

implementation group: 'com.newrelic.agent.java', name: 'newrelic-api', version: '5.+'

Or can I? Tried something like below but to no avail..

implementation(group: 'com.lib', name: 'starter-web', version: '0.+') {
      implementation("com.newrelic.agent.java:newrelic-api")
}

Upvotes: 0

Views: 239

Answers (1)

Cisco
Cisco

Reputation: 22952

Since they switched from the compile configuration implementation, you now need to add a dependency on whatever you were depending on.

implementation "com.lib:starter-web:0.+"
implementation "com.newrelic.agent.java:newrelic-api"

The compile configuration is deprecated, so if the library author switched to implementation, then that may mean their usage of com.newrelic.agent.java:newrelic-api was an implementation detail of com.lib:starter-web. You can think of it as the "private" inner workings of the library.

If com.lib:starter-web exposed classes or utilities for consumers to use in their projects that made use of newrelic-api, then the library author should have used api to make it "public".

Upvotes: 1

Related Questions