I am using composite build to manage my plugins. In the same composite build, I have DetektConventionPlugin
plugin shown below and I wish to apply it using this pattern: apply<DetektConventionPlugin>()
. However, this is not working with composite build but it works for buildSrc but I do not wish to continue using buildSrc.
class DetektConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
val detektVersion = libs.findVersion("detekt").get().toString()
pluginManager.apply("io.gitlab.arturbosch.detekt")
extensions.getByType<DetektExtension>().apply {
toolVersion = detektVersion
source = files("$rootDir/")
parallel = true
config = files("$rootDir/config/detekt/detekt-config.yml")
buildUponDefaultConfig = true
allRules = false
baseline = file("$rootDir/config/detekt/detekt-baseline.xml")
// dependencies {
// "detektPlugins"(libs.findLibrary("detekt-formatting").get())
// }a
}
tasks.named<Detekt>("detekt").configure {
description = "Runs Detekt on the whole project at once."
reports {
html.required.set(true)
html.outputLocation.set(
file("$rootDir/build/reports/detekt.html"),
)
}
parallel = true
setSource(projectDir)
include("**/*.kt", "**/*.kts")
exclude("**/resources/**", "**/build/**")
// exclude other custom generated files
}
dependencies {
detekt("io.gitlab.arturbosch.detekt:detekt-cli:$detektVersion")
}
}
}
}
I am not sure what I am doing wrong here. Looks like buildSrc handles plugins differently.