Skip to content

Instantly share code, notes, and snippets.

@Fleshgrinder
Last active March 29, 2021 08:32
Show Gist options
  • Save Fleshgrinder/6431aea38c1c694554ab3756f6365247 to your computer and use it in GitHub Desktop.
Save Fleshgrinder/6431aea38c1c694554ab3756f6365247 to your computer and use it in GitHub Desktop.
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 { it.group != "org.junit.vintage" }
?.exclude("junit", "junit")
?.exclude("org.junit.vintage")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment