gradle-lint-plugin
gradle-lint-plugin copied to clipboard
Is there any way to create a custom rules for 'gradle-lint-plugin' and add them to the classpath?
Hi,
In this article https://github.com/nebula-plugins/gradle-lint-plugin/wiki/Writing-A-Rule there is an instruction on how to create a rule.
In case if I want to implement several rules for my own team, how can I use them within gradle-lint-plugin?
For example, Gradle PMD plugin supports dependency section (with dependency scope=pmd) that allows connecting other rules implemented outside the PMD team
https://docs.gradle.org/current/userguide/pmd_plugin.html#sec:pmd_dependency_management
apply plugin: 'pmd'
dependencies {
...
pmd "io.github.dgroup:arch4u-pmd:${version}" // use latest arch4u-pmd rules version
...
}
pmd {
consoleOutput = true
ruleSetFiles = files("io/github/dgroup/arch4u/pmd/arch4u-ruleset.xml")
...
}
Did you land somewhere with this, @dgroup? I asked a similar question in #395 before seeing yours.
@exaucae, I made a fork with several rules and applied them to my projects directly.
Thank you!
this line could be the one to change if we want to feed custom rules to the plugin: https://github.com/nebula-plugins/gradle-lint-plugin/blob/280804cbbdcce703284921b34fe8719a0a84f661/src/main/groovy/com/netflix/nebula/lint/plugin/GradleLintPlugin.groovy#L33
The classloader is used by the LintRuleRegistry to get rulesets: https://github.com/nebula-plugins/gradle-lint-plugin/blob/main/src/main/groovy/com/netflix/nebula/lint/plugin/LintRuleRegistry.groovy#L27-L31