How to disable transitive compile dependencies

I’m not sure if it works, but you can try to declare 3rd party dependencies as follows

dependencies {
    implementation ('group:name:version') {
        transitive = false
    }
    runtimeOnly  ('group:name:version') // hopefully adds transitive dependencies for testing

this should add the transitive dependencies at runtime, but remove them from compilation, though I haven’t tested this.

But be aware that you may encounter dependencies you’ll need to add, even though you never use them directly. Using/overwriting methods from a super classes super class that was such a case for me.