Exclude dependency from `jar` task

I want/need to exclude a dependency (and all it’s transitive dependencies) from the jar task but I am not sure how to achieve that. (For example ignore all dependencies and transitive dependencies of a specific configuration from the jar task)

By default, the jar task zips only your compiled class files and resources. It does not include any dependencies in the jar by default. I’m guessing you’ve customised your jar task. Please share the related build script