https://kotlinlang.org logo
#detekt
Title
# detekt
d

dead.fish

05/22/2020, 11:03 AM
I'd like to move my custom Detekt configuration into a Gradle plugin in buildSrc later on, so at this point a
detektPlugins(project("..."))
configuration would no longer work anyways...
j

Javier

05/22/2020, 11:21 AM
Add this to dependencies block inside build.gradle.kts (buildSrc)
implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detekt")
d

dead.fish

05/22/2020, 11:27 AM
Ah, I only applied
detekt-api
there, applying the plugin there should work?! Nice!
No, this didn't work unfortunately 😞 The custom ruleset is not found.
j

Javier

05/22/2020, 11:52 AM
That
implementation
let you use
detektPlugins
in precompiled plugins
For example, this is my own plugin for detekt
It is in buildSrc
And I can apply it to the modules so
The filename for my detekt plugin is Detekt.gradle.kts
d

dead.fish

05/22/2020, 12:14 PM
Hrm... weird, this doesn't look like a standard plugin (that has to be wrapped into a
Plugin<Project>
derived class) at all, but if this works for you, well.
I worked around it for now by using
Copy code
dependencies {
  val detektPlugins by configurations
  detektPlugins(files("$rootDir/buildSrc/build/libs/buildSrc.jar"))
}
Still haven't moved my Detekt configuration to buildSrc, but only have the additional rules there
j

Javier

05/22/2020, 12:25 PM
It is a precompiled plugin
It is easier to use
a

Artur Bosch

05/26/2020, 10:51 AM
Hi, we are doing the same at our repo with precompiled plugins and project dependencies as
detektPlugins
: https://github.com/detekt/detekt/blob/master/buildSrc/src/main/kotlin/detekt.gradle.kts#L45
j

Javier

05/26/2020, 12:04 PM
@Artur Bosch can you take a look to this issue? https://github.com/detekt/detekt/issues/2732
d

dead.fish

06/09/2020, 10:26 AM
@Artur Bosch Sorry for the late reply. Actually, I kind of dislike of having more than
buildSrc
as build configuration source. I see however that Gradle provides no clean way to access the
buildSrc
module itself for this configuration, probably because of https://github.com/gradle/gradle/issues/2531
56 Views