Justin Breitfeller
04/18/2024, 2:53 PMJustin Breitfeller
04/18/2024, 2:54 PMyum {
loggingConfiguration {
dependencies {
"implementation"(projects.logging)
"testImplementation"(libs.slf4j.simple)
}
}
}
The root convention plugin method looks like:
fun loggingConfiguration(action: Project.() -> Unit) {
YumGlobalConfigService.of(project).get().loggingConfiguration = action
}
Then each child project's extension calls the following method when I enable logging
private fun Project.addLoggingSupport() {
val service = YumGlobalConfigService.of(this).get()
service.loggingConfiguration(this)
}
Important to note that YumGlobalConfigService.of
is a shared build service
fun of(project: Project): Provider<YumGlobalConfigService> {
return project.gradle
.sharedServices
.registerIfAbsent(
"YumGlobalConfigService",
YumGlobalConfigService::class.java
) {
/* do no config */
}
}