Last active
March 29, 2021 08:32
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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