Similar to the previous question...I do also have ...
# gradle
x
Similar to the previous question...I do also have a multi-project build in Kotlin DSL; I'm looking for ways to apply the
detekt
plugin in the
subprojects
block. This is what I have so far: https://gist.github.com/x80486/52d5b8f1d584f90732e7d1881df423a7, but Gradle tells me that
detekt
is not recognizable. I would like to avoid to configure
detekt
in all subprojects, that's what I'm really trying to do. Anyone have done this before?
a
Because you’re dynamically applying the detekt plugin using
apply
, the Kotlin code for the build file doesn’t have the helper for the detekt extension available. You’ll have to replace the
detekt {
bit with an explicit reference to the class to configure, e.g.
the<DetektExtension>().apply {
👍 1
🤔 1
To expand on that: Gradle grabs the head of the build scripts and manually parses the
plugins{}
bit, and uses that to figure out which plugins to load and generates some “glue” for the Kotlin DSL - you can see this generated code for any project with sth like
./gradlew subproject:kotlinDslAccessorsReport
— if you manually add the plugins block to a subproject and run that, you should be able to see what the implementation of the
Project.detekt { }
extension would be
👏 1
👍 1
x
I see what you meant...let me play with that! Thanks again! Still,
detekt
behaves strange, it reports the issues for every module in all modules 🤷‍♂️
The
./gradlew subproject:kotlinDslAccessorsReport
is the thing to visualize that! 👌