qulice icon indicating copy to clipboard operation
qulice copied to clipboard

Incorrect warning about unused declared dependencies causes build failure

Open TheJavaGuy opened this issue 9 years ago • 12 comments

In some situations Qulice incorrectly reports "Unused declared dependencies found" which causes build failure. In reality, the dependency is used in code. Maven dependency plugin 2.10 reports "No dependency problems found" on the same project. This could maybe be due to Qulice using version 1.5 of Apache Maven Dependency Analyzer while version 1.6 exists (http://mvnrepository.com/artifact/org.apache.maven.shared/maven-dependency-analyzer)

Steps to reproduce:

  1. git clone https://github.com/RokiShopen/RandomDataGenerator.git
  2. cd RandomDataGenerator/
  3. git checkout experiment-datafiles
  4. mvn -e clean dependency:analyze -PRandomDataGenerator

After step 4 Qulice will report [WARNING] Unused declared dependencies found: org.thejavaguy:rng:jar:0.0.2:compile and fail the build. More detailed log is attached here bug_qulice_dependency_log.txt

When you try mvn -e clean dependency:analyze -PNoQulice you'll see that all dependencies are OK: [INFO] No dependency problems found

Environment used: Ubuntu 14.04LTS, Maven 3.3.9, Java 1.8.0_91

TheJavaGuy avatar Jun 16 '16 08:06 TheJavaGuy

I have tested it on Win7, Maven 3.3.9, Java 1.8.0_77 and I have same behavior.

RokiShopen avatar Jun 17 '16 14:06 RokiShopen

@TheJavaGuy interesting, we usually didn't have problems if it wasn't annotation

krzyk avatar Jun 17 '16 18:06 krzyk

@TheJavaGuy thanks for the report

krzyk avatar Jun 17 '16 18:06 krzyk

@davvd valid bug

krzyk avatar Jun 17 '16 18:06 krzyk

@davvd valid bug

@krzyk I tagged this as "bug"

davvd avatar Jun 20 '16 09:06 davvd

@davvd this is postponed

krzyk avatar Aug 13 '16 11:08 krzyk

@davvd this is postponed

@krzyk right, I added "postponed" label

davvd avatar Aug 15 '16 08:08 davvd

@davvd this is postponed

@krzyk someone else will help in this task, no problem at all

davvd avatar Aug 15 '16 08:08 davvd

@krzyk for the record, this is caused by the fact that annotations are not taken into account by bytecode analysis.

This is a known problem with maven-dependency-plugin, see its documentation where it says:

In rare cases it is possible to have dependencies that are legitimate on the classpath but cause either "Declared but unused" or "Undeclared but used" warnings. The most common case is with jars that contain annotations and the byte code analysis is unable to determine whether a jar is actually required or not.

victornoel avatar May 10 '18 14:05 victornoel

@krzyk just to add to @victornoel's comment above, this will also apply when only constants are referenced from the jar. (static finals that are of primitive types or Strings, and are initialized with constants or expressions that can be completely evaluated at compile time.) Values for these are effectively "inlined", so no reference is apparent in the bytecode.

graham-h avatar Jan 23 '19 16:01 graham-h

Unused declared dependencies found: org.apache.spark:spark-catalyst_2.11:jar:2.4.5:compile org.apache.spark:spark-core_2.11:jar:2.4.5:compile org.apache.spark:spark-mllib-local_2.11:jar:2.4.5:compile org.apache.spark:spark-sql_2.11:jar:2.4.5:compile

can anyone please help me out with this one? I added this jars in pom.xml file in dependency

34venu avatar Mar 04 '20 10:03 34venu

+1

RoRoche avatar Mar 23 '21 13:03 RoRoche