gradle-lint-plugin icon indicating copy to clipboard operation
gradle-lint-plugin copied to clipboard

Rule `all-dependency` fails when applied on Kotlin module with no `stdlib` usages

Open fondesa opened this issue 2 years ago • 0 comments

Currently, the Kotlin plugin adds the dependency org.jetbrains.kotlin:kotlin-stdlib:$version automatically to Kotlin modules. This dependency is added in the configurations $DependenciesMetadata (e.g. implementationDependenciesMetadata, apiDependenciesMetadata) and not in implementation and api. Running ./gradlew generateGradleLintReport with the rule all-dependency, fails on Kotlin modules which are not using directly standard library APIs.

The violations on those modules are the following:

Violation: Rule=unused-dependency P=1 Line=null Msg=[one or more classes in org.jetbrains.kotlin:kotlin-stdlib:1.8.0 are required by your code directly]
Violation: Rule=undeclared-dependency P=1 Line=null Msg=[one or more classes in org.jetbrains.kotlin:kotlin-stdlib:1.8.0 are required by your code directly]

Proposals which would probably fix this:

  1. query the $DependenciesMetadata configs internally
  2. expose an API in GradleLintExtension to exclude dependencies from all-dependency checks (e.g. gradleLint.skipDependencies = "org.jetbrains.kotlin:kotlin-stdlib")

fondesa avatar Feb 06 '23 14:02 fondesa