Slackbot
07/12/2022, 4:20 PMBen Madore
07/12/2022, 5:00 PMlogback-core
and rely on the excludes to manage transitives in the published pom
/ module
melix
07/12/2022, 7:13 PMconfigurations.all {
if (it.canBeConsumed) {
allDependencies.all {
if (it instanceof ExternalModuleDependency) {
if (it.group == 'ch.qos.logback' && it.name == 'logback-core') {
throw new InvalidUserCodeException("Oh noes, you are not allowed to expose logback!")
}
}
}
}
}
Ben Madore
07/12/2022, 7:44 PMconfigurations.configureEach {
val configName = this.name
// If the bucket is meant for dependency declarations, and is not intended for testing
// We fail the build if a direct dependency is declared on a banned library
if (!this.isCanBeResolved && !this.isCanBeConsumed && !configName.contains("test")) {
dependencies.configureEach {
if (isBannedDependency(this)) {
throw GradleException(
"""
|Conventions Plugin: Invalid dependency declaration on a dependency banned in this context. Remove dependency declaration:
| $configName("${this.group}:${this.name}")
""".trimMargin()
)
}
}
}
// Handles _transitive_ dependencies, ensuring they are excluded from any generated maven pom files (*Elements
// configurations) as well as the configurations used when building and running the module (*Classpath
// configurations)
// They are though, still allowed to be used for any tests
if (name == "runtimeClasspath" || name == "compileClasspath" || name == "runtimeElements" || name == "apiElements") {
sharedLibraryBannedDependencies.entries().forEach {
exclude(group = it.key, module = it.value)
}
}
}
This seems to fail if any direct dependencies are declared, but not fail for any transitives (e.g. from a platform)… but it also excludes any transitives from being included in the published pom/module.Ben Madore
07/12/2022, 7:47 PMBen Madore
07/12/2022, 7:47 PMmelix
07/12/2022, 7:49 PMmelix
07/12/2022, 7:49 PM