Exclude transitive dependencies of a transitive dependency

I have a direct dependency A. A has a dependency on B. I would like to exclude all of B’s transitive dependencies. Is there a clean way to do this using the standard configurations/dependencies exclude syntax?