Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect warning about unused declared dependencies causes build failure #782

Open
TheJavaGuy opened this issue Jun 16, 2016 · 12 comments
Open

Comments

@TheJavaGuy
Copy link

TheJavaGuy commented Jun 16, 2016

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

@RokiShopen
Copy link

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

@krzyk
Copy link
Collaborator

krzyk commented Jun 17, 2016

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

@krzyk
Copy link
Collaborator

krzyk commented Jun 17, 2016

@TheJavaGuy thanks for the report

@krzyk
Copy link
Collaborator

krzyk commented Jun 17, 2016

@davvd valid bug

@davvd
Copy link

davvd commented Jun 20, 2016

@davvd valid bug

@krzyk I tagged this as "bug"

@krzyk
Copy link
Collaborator

krzyk commented Aug 13, 2016

@davvd this is postponed

@davvd
Copy link

davvd commented Aug 15, 2016

@davvd this is postponed

@krzyk right, I added "postponed" label

@davvd
Copy link

davvd commented Aug 15, 2016

@davvd this is postponed

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

@davvd davvd mentioned this issue Aug 15, 2016
@victornoel
Copy link

@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.

@graham-h
Copy link

@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.

@34venu
Copy link

34venu commented Mar 4, 2020

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

@RoRoche
Copy link

RoRoche commented Mar 23, 2021

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants