Force a transitive dependency version


(las) #1

I am developing a library which depends on several dependencies. I want to force versions for certain dependencies of my library and i don’t want them to be overridden by the client. How can something like this be implemented?


(las) #2

Is there a solution for this problem?


(las) #3

Is there any solution for this other than writing a plugin and asking clients to include the plugin?


(las) #4

Anyone has any solution for this please?


(uklance) #5

I want to force versions for certain dependencies of my library

That can be done in a resolutionStrategy

i don’t want them to be overridden by the client

I’m not sure what you are asking here. Are you asking that gradle projects depending on your library should be denied the opportunity to force their own version? That’s a but hypocritical of you given your first request. Gradle won’t somehow disable this feature for your clients


(las) #6

I understand forcing version using resolution strategy to avoid my transitive dependencies bringing higher version.

I am looking for ways i can do the same if my library is added as a dependency by a client where the client application and my library have a common dependency but i want to dictate the version. I understand that spring-boot plugin has implemented similar feature and i am looking for a way other than a custom plugin.


(uklance) #7

As I said it seems a bit hypocritical to benefit from this feature yourself but want to deny the same feature to your clients. And no, gradle won’t disable this feature for your clients.

Perhaps, instead, you could repackage a dependency using shadow. This way a client could use a different version without affecting your library’s functionality. This is how libraries like hibernate and spring bring in the asm dependency