gradle-lint-plugin
gradle-lint-plugin copied to clipboard
gradleLint.ignore('unused-dependency') is not working
in multi module project I have in the root build.gradle
gradleLint {
rules = ['unused-dependency']
criticalRules = ['undeclared-dependency']
}
and in one of the sub module build.gradle
dependencies {
gradleLint.ignore('unused-dependency') {
compileOnly 'com.foo:bar:0.1'
}
}
however I get the following warning
warning unused-dependency this dependency is unused and can be removed
compileOnly 'com.foo:bar:0.1'
Same Problem here, Multi Module Project, using gradleLint.ignore('unused-dependency') {} for an unused dependency (api scope), but still get the validation error
warning unused-dependency this dependency is unused and can be removed
mycreon-test/build.gradle:11
api "net.netzgut.integral:integral-testify:${versions.integralTestify}", {
exclude group: 'org.apache.tapestry'
exclude group: 'org.testng', module: 'testng'
}
I have setup a small example project:
https://github.com/felixgonschorek/gradle-lint-tests/blob/master/build.gradle#L17
id 'nebula.lint' version '17.1.1'
tested with Java 11 and Java 16
hello, unfortunately, this is a quirk of rules that operate on resolved dependencies. The rule is not touching the declaration in a build file so wrapping it in ignore is not affecting the rule.
Thank you for the feedback! I misunderstood the feature then :)
Is there any other way to tell gradle-lint plugin to not report unused dependencies or used transitive dependencies? A blacklist or custom rule-filter file or anything that is then applied to the resolved dependencies?
If not, I may consider implementing and offering to contribute a crude implementation of such a feature.
@felixgonschorek unfortunately, there is no way to exclude dependencies from those checks. It might be a bit tricky to implement. The idea is that the rules are plug and play and there are no specific configurations within the plugin extension. You could potentially have a special extension for the rule but rules don't have a good lifecycle phase where you could create.
Feel free to look around the code and share your thoughts if you find some direction.
I should add that we internally don't use the unused dependency rule and you can see their state reflects that. There are a lot of edge cases like this one. We maintain it at the level that current tests will pass but we cannot afford a bigger time investment