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

'unused-dependency' mark every dependencies as unused

Open lucblender opened this issue 7 years ago • 7 comments
trafficstars

For every dependency I always get: warning unused-dependency this dependency is unused and can be removed

Here is my gradle file

buildscript { repositories { jcenter() } } plugins { id 'java' id 'nebula.lint' version '9.3.4' } version = '1.2' group = 'ch.hevs.lucas'

repositories { jcenter() } gradleLint { rules = ['unused-dependency'] }

dependencies { compile... }

Gradle Version:

Gradle 4.10

Build time: 2018-08-27 18:35:06 UTC Revision: ee3751ed9f2034effc1f0072c2b2ee74b5dce67d

Kotlin DSL: 1.0-rc-3 Kotlin: 1.2.60 Groovy: 2.4.15 Ant: Apache Ant(TM) version 1.9.11 compiled on March 23 2018 JVM: 10.0.2 (Oracle Corporation 10.0.2+13-Ubuntu-1ubuntu0.18.04.1) OS: Linux 4.15.0-33-generic amd64

lucblender avatar Sep 05 '18 11:09 lucblender

Hello @lucblender we run tests for unused dependencies (https://github.com/nebula-plugins/gradle-lint-plugin/blob/63ecac13b7e6aa4fdf406e38f77ebde8251f192c/src/test/groovy/com/netflix/nebula/lint/rule/dependency/UnusedDependencyRuleSpec.groovy) using Gradle 4.10 and they are passing. Would you please share a project example which shows the problem you are seeing?

chali avatar Sep 06 '18 20:09 chali

Could the cause be that you are using a java version >= 9? (see https://github.com/nebula-plugins/gradle-lint-plugin/issues/155)

Olard avatar Sep 10 '18 08:09 Olard

Thanks for you feedback. @chali I first tried on a big project and since it wasn't sucessful I went to see the issues and made a simple project with only one main as #187. @Olard yes you are right here is more detail of my java version java -version openjdk version "10.0.2" 2018-07-17 OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1) OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1, mixed mode)

lucblender avatar Sep 17 '18 06:09 lucblender

I tried to specify an other version of java in the build.gradle and gradle.properties files repectively with compileJava.options.fork = true compileJava.options.forkOptions.executable = 'javacPATH' & org.gradle.java.home=jdkPATH

With this java version it is working: java version "1.8.0_181" Java(TM) SE Runtime Environment (build 1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

lucblender avatar Sep 17 '18 08:09 lucblender

Unfortunately, we are not using Java 10 right now. Because we are working on other priorities we won't get to this issue soon. We have some plans to move to Java 11 it will take definitely months before we will get there. I'm happy to take a look at your PRs if you are interested in fixing this problem.

chali avatar Sep 19 '18 23:09 chali

@chali thank you for all the information! I went back to my big project and with using another version of java it seems to work perfectly. The only problem I've now is that I've a dependency that need other dependencies and those are detected as 'unused-dependency'. I don't know if 'unused-dependency' is supposed to look inside libraries jar to find their dependency or if it's not made. I don't know if my comment is clear. Maybe this is worth to open an other issue?

lucblender avatar Sep 21 '18 09:09 lucblender

any update on java version? I'm using java 11 and still saw some dependencies false positively marked as unused

yangzii0920 avatar Apr 29 '22 15:04 yangzii0920