No this will not error out. Transitive dependencies are added to the
compile classpath, so compilation will succeed.
However, it is best practice to explicitly declare all direct dependencies
for a project.


Yes, it's true but I think it's interesting to have a plugin that analyze
your project and generate an HTML report
with potentials problems like used undeclared dependencies, unused declared
dependencies...

For the moment, you can use the maven-dependency-analyzer-plugin ([1])
mvn dependency-analyzer:analyze
[...]
[INFO] [dependency-analyzer:analyze]
[INFO] Used declared dependencies:
[INFO]    junit:junit:jar:3.8.2:test
[INFO] Used undeclared dependencies:
[INFO]    log4j:log4j:jar:1.2.14:compile
[INFO] Unused declared dependencies:
[INFO]    test.mutlimodules.dependencies:module1:jar:1.0-SNAPSHOT:compile
[...]

it not works with multi-modules project, you have to execute the command in
each module.

HTH,

Rémy

[1] http://www.nabble.com/unused-dependencies-tf3265948s177.html#a9078769

Reply via email to