Publish artifact to maven with only a direct dependency bundeled in with transitive dependencyes defined in pom

I have a project on github that consists of three parts, a client, a server and some shared code.

I’ve split this into three gradle projects and have both the server and the client locally depend on the shared project.

The problem now is when I publish the client with the maven-publish plugin it obvously dosen’t include any dependencies. The thing is I don’t want to publish the shared library as an extra project as it dosen’t make sense as a single project just in the context of either the server or the client.

I found an answer on this forum that promised to do that.

Unfortunatly after I inspected my jar file I noticed that it included all dependencies not just a specific one. I noticed that it includes all the dependencies of the shared module.

My build.gradle can be found on github.

After some further research and playing around with gradle I found that my question was wrong. What I want to do is include only the contents of the artifact generated by the shared jar without any of it’s transitive dependencies. But I obviously still need to have those dependencies included in the dependency part of the published maven pom file so that programms consuming my library know that they need all of those dependencies.

So my question is how can I bundle that one jar into my jar without dependencies, but exclude all of it’s dependencies from beeing bundled while adopting it’s dependencies as dependencies of my project?