Hi everyone, I’m centralising common gradle plugin...
# plugin-development
b
Hi everyone, I’m centralising common gradle plugins (and config) in team specific gradle plugin. Now I hit problem with merging plugin extensions. So my QualityPlugin applies Detekt and configures detekt to run all rules:
Copy code
class QualityPlugin : Plugin<Project> {
    override fun apply(target: Project) {
        target.pluginManager.apply(DetektPlugin::class.java)

        target.extensions.configure(DetektExtension::class.java) {
            allRules = true
        }
    }
}
Now I have a project where I want to apply my QualityPlugin and, additionally, set a Detekt base line:
Copy code
plugins {
 id("my quality plugin name")
}
 
detekt {
    baseline = file("config/detekt-baseline-test.xml")
}
I was expecting Gradle to graciously merge the
allRules
and
baseline
settings in the DetektExtension but alas. The baseline is ignored. What am I doing wrong? Thanks
t
the way I am reading that it should be working as you expect. plugin apply is going to setAllRules = true and then it will return to the build script and run your detekt config block.
👆 1
b
Was reading upon Lazy Configuration and wondering whether that would be required for above to work as expected? As it is, the
baseline
property of
DetektExtension
is defined as
File
and not as
Provider<File>