Exclude transitive dependencies another local project?

Hi. So I am not sure if what I am asking or if it is even possible, but would love some input.

I developing something as a part of a larger project. In this project I am using Dropwizard, which has a lot of moving parts. The larger project has a ‘shared’ project which has various things relevant to multiple parts of the project (including what I am working on) but some of the things that the ‘shared’ project imports creates conflicts with dropwizard for example with logging, an example of error messages :


Now I have tried different ways to exclude the slf4j-log4j12 when importing the shared project in to my project but it either seems to not import the project at all, or import the project with the modules that cause trouble.

Now I can go in to the build.gradle of the shared project, and remove the depency of the /slf4j-log4j12 module, but that might in turn mean I am removing a module that some other project might depend on. So I am wondering how I make it so that when my project imports the ‘shared’ project it will exclude the /slf4j-log4j12, or in the ‘shared’ project build gradle, make it so it excludes modules, but only when imported into my project?

Have tried making a configuration for it, and also just excluding it when I import the project, but neither seems to work. The build gradle.file of the project I am working on (and one of my attempts to resolve this):


Have been banging my head against this wall for way to many hours now without making meaningful headway. Help much appreciated