Java Tip of the Week #6 – Maven Dependencies

posted by Roberto Cortez on

This week Java Tip of the Week is about Maven. I’ve recently had session at Jfokus, called Maven Taming the Beast with the following abstract:

Maven Taming the Beast

Love it or hate it (and a lot of people seem to hate it), Maven is a widely used tool. We can consider that Maven has been the de-facto standard build tool for Java over the last 10 years. Most experienced developers already got their share of Maven headaches. Unfortunately, new developers are going through the same hard learning process, because they don’t know how to deal with Maven particularities. “Why is this jar in my build?”, “I can’t see my changes!”, “The jar is not included in the distribution!”, “The artifact was not found!” are common problems. Learn to tame the Maven Beast and be in complete control of your build to save you countless hours of pain and frustration.

And here are the slides:

Maven Dependencies

Since the presentation was only 15 minutes long (video should be available later), I made this week Java Tip of the Week a small demo of some of the issues discussed and the commands you can use to fix them:

For reference, here are the commands:

mvn dependency:listDisplays the list of dependencies for the project.
mvn dependency:treeDisplays the dependency tree for the project, including transitive dependencies.
mvn dependency:analyzeAnalyzes the dependencies of the project and determines which are: used and declared; used and undeclared; unused and declared.
mvn dependency:tree -DverboseDisplays the dependency tree for the project, including transitive dependencies and omitted dependencies due to Dependency Mediation.
mvn install -Dmaven.repo.local=/tmp/.m2Points Maven local repository to a new directory, forcing Maven to download everything again.

Also, check this other post I wrote: Maven Common Problems and Pitfalls.

Remember to follow my Youtube channel for faster updates!

Leave a comment if you enjoyed it, if not leave one as well!

Leave a reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>