Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to create a custom rules for 'gradle-lint-plugin' and add them to the classpath? #371

Open
dgroup opened this issue Mar 7, 2022 · 4 comments

Comments

@dgroup
Copy link

dgroup commented Mar 7, 2022

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")
   ...
}
@exaucae
Copy link

exaucae commented Aug 29, 2023

Did you land somewhere with this, @dgroup? I asked a similar question in #395 before seeing yours.

@dgroup
Copy link
Author

dgroup commented Aug 29, 2023

@exaucae, I made a fork with several rules and applied them to my projects directly.

@exaucae
Copy link

exaucae commented Aug 30, 2023

Thank you!

exaucae added a commit to exaucae/tutorials that referenced this issue Sep 13, 2023
It's impossible unless one forks the library and adds them directly:
See nebula-plugins/gradle-lint-plugin#371 (comment)
@exaucae
Copy link

exaucae commented Sep 13, 2023

this line could be the one to change if we want to feed custom rules to the plugin:

LintRuleRegistry.classLoader = getClass().classLoader

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants