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

nkiesel

07/09/2020, 12:59 AM
How can I override settings from a global detekt settings in a module for a multi-module gradle build? Right now I have a
detekt-config.yml
in my root directory, and another `detekt-config.yml`in my module directory. To use both, I use
detekt { config = files("${project.rootDir}/detekt-config.yml", "detekt-config.yml") }
. Is there a better way which e.g. does not require to repeat the base config file name or perhaps even a
mergeConfigs: true
which will automatically merge these? I tried
detekt { config += files("detekt-config.yml") }
but that did not work.
g

gammax

07/09/2020, 7:59 PM
Is there a better way which e.g. does not require to repeat the base config file name
You should be able to write a Gradle function (let’s call it
mergeBaseConfigWith
) that returns a
ConfigurableFileCollection
(is Gradle type) and do something like:
Copy code
detekt { config = mergeBaseConfigWith("detekt-config.yml") }
n

nkiesel

07/13/2020, 1:26 AM
This would still require to have programmatic access to the root config file (or file name), which I don't think I have.
2 Views