Friday, January 19, 2018

gradle lint plugin to remove unused dependencies

In parent project,  Add the following code in build.gradle or init.gradle

buildscript {
repositories { maven { url("https://plugins.gradle.org/m2/") } }
dependencies {
classpath 'com.netflix.nebula:gradle-lint-plugin:latest.release'
}
}
plugins {
id 'java'
id 'groovy'
id 'maven'
id 'jacoco'
id 'application'
id 'nebula.lint' version '7.4.0'
}
allprojects {
  apply plugin: 'nebula.lint'
  gradleLint.rules = ['unused-dependency']
}

Then run the following command:

gradle lintGradle
gradle fixGradleLint
gradle compileJava fixGradleLint


  1. https://github.com/nebula-plugins/gradle-lint-plugin/issues/38
  2. https://stackoverflow.com/a/25525390
  3. https://discuss.gradle.org/t/task-run-not-found-in-root-project/12130/3
  4. https://github.com/wfhartford/gradle-dependency-analyze
  5. https://www.youtube.com/watch?v=0ZS_bqD1dkg

No comments:

Post a Comment