-
Notifications
You must be signed in to change notification settings - Fork 42
Description
Reported by a customer (internal conversation). In their words, given this tripped them up...
Initial Report:
class
HttpPaginatedResponse, returned byAblyRest.requestmethod returns an array ofcom.google.gson.JsonElementfrom itsitems()method, yet the ably-java library (v1.1.10) declares only a runtime dependency on GSON library, leading my IDE to flag calls to the items() method as an error with message ‘Cannot access com.google.gson.JsonElement’. Interested to know why GSON is not a compile-time dependency given its classes are used in the public API of ably-java?
Follow-up opinion as to how this should be instead:
implementationresults in those dependencies being declared as ‘runtime’ dependencies in the published POM, hence they are transitively included in the consuming applications runtimeClasspath but not the compileClasspath. Personally, I would consider having GSON as anapidependency in the project (this would also require use of the Gradle ‘java-library’ plugin rather than the plain ‘java’ plugin), meaning it would end up as ‘compile’ dependency in the ably-java POM and thus be available in the compileClasspath of consuming applications. I suspect what may have happened is that when the original Gradlecompilescope (which resulted in dependencies being published as ‘compile’ scope in the POM) was deprecated, someone simply replaced it withimplementation(as I originally did in all my personal projects!) without fully appreciating the subtle difference betweenimplementationandapi.
Like most things, no right or wrong (there are downsides to using
api), but maybe worth thinking about. https://docs.gradle.org/current/userguide/java_library_plugin.html
┆Issue is synchronized with this Jira Research by Unito