Incorrect warning about unused declared dependencies causes build failure
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:
- git clone https://github.com/RokiShopen/RandomDataGenerator.git
- cd RandomDataGenerator/
- git checkout experiment-datafiles
- 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
I have tested it on Win7, Maven 3.3.9, Java 1.8.0_77 and I have same behavior.
@TheJavaGuy interesting, we usually didn't have problems if it wasn't annotation
@TheJavaGuy thanks for the report
@davvd valid bug
@davvd valid bug
@krzyk I tagged this as "bug"
@davvd this is postponed
@davvd this is postponed
@krzyk right, I added "postponed" label
@davvd this is postponed
@krzyk someone else will help in this task, no problem at all
@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.
@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.
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
+1