UPDATE: 06/28/2016: Android support for unused dependency
In June 2017, they released 4.0.0 version and renamed the root project name "gradle-lint-plugin" to "nebula-lint-plugin" . They also added Android support for unused-dependency .
In May 2016, Gradle implemented the gradle lint plugin to find and remove unwanted dependencies.
The Gradle Lint plugin is a plug-in and customizable tool for handling the detection and reporting of abuse patterns or Gradle scripts and related files.
This plugin has different rules. An unused dependency rule is one of them. It has 3 specific characteristics.
- Removes unused dependencies.
- Promotes transitive dependencies that are used directly by your code to explicit first-order dependencies.
- Translates dependencies into the βcorrectβ configuration.
To apply the rule, add:
gradleLint.rules += 'unused-dependency'
Details The unused dependency rule is indicated in the last part.
Application of the Gradle lint plugin:
buildscript { repositories { jcenter() } } plugins { id 'nebula.lint' version '0.30.2' }
As an alternative:
buildscript { repositories { jcenter() } dependencies { classpath 'com.netflix.nebula:gradle-lint-plugin:latest.release' } } apply plugin: 'nebula.lint'
Determine which rules you want to use:
gradleLint.rules = ['all-dependency']
To build an enterprise, we recommend defining the lint rules in the init.gradle script or in the Gradle script, which is enabled using Gradle using a mechanism.
For projects with several modules, it is recommended to use the plugin in the allprojects block:
allprojects { apply plugin: 'nebula.lint' gradleLint.rules = ['all-dependency']
To apply the rule, add:
gradleLint.rules += 'unused-dependency'
The rule checks the compiled binaries coming from your source sets project, looking for class references and compares these links with the dependencies that you specified in your dependency block.
In particular, the rule performs the following dependency changes:
1) Removes unused dependencies
- Family-style banks, such as com.amazonaws: aws-java-sdk, are deleted because they do not contain code
2) Promotes transitive dependencies that your code directly uses for explicit first-order dependencies
- This has the side effect of breaking up family-style bars like com.amazonaws: aws-java-sdk into the parts that you are actually using and adding them as first-order dependencies
3) Moves dependencies to the "correct" configuration
- Webjars move to runtime configuration
- Boxes that do not contain classes AND content outside META-INF are moved at run time
- 'xerces', 'xercesImpl', 'xml-apis' should always be runtime regions
- Service providers (banks containing META-INF / services), for example mysql-connector-java, move at run time if there is no compile-time provable
- Dependencies move into the configuration with the highest source code possible. For example, "junit" is ported to testCompile if there is an explicit dependency on it in the main set of sources (rarely).
UPDATE: Previous plugins
For your kind information, I want to share with previous plugins
But the latest version 1.0.3 was created on December 23, 2014 . After this update, no.
NB: Many of our engineers are confused about this plugin because they only updated the version number of nothing.