Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Disallow transitive JUnit 4 and JUnit 5 Vintage dependencies in all Gradle configurations.
configurations.all {
// If this configuration supports transitive dependencies then we
// exclude any transitive JUnit 4 dependencies from all dependencies
// that are declared in this configuration. This means that users have
// to define an explicit dependency on JUnit 4 if they want to use it.
if (isTransitive) {
withDependencies {
forEach {
(it as? ExternalModuleDependency)
?.takeIf { != "org.junit.vintage" }
?.exclude("junit", "junit")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment