The best Maven how-tos from the Sonatype blog

July 15, 2011 By Brian Fox

4 minute read time

Sonatype is going through the archives and digging up articles that we think would be useful to developers using our tools. If you use Maven, keep reading the post below from Sonatype Vice President of Engineering Brian Fox on Maven best practices and how-tos.

---

We have a handful of Maven best practice and how-tos documented in the blogs. Over time they get buried by newer posts, but the content is still just as relevant. Learn more about Maven by checking out the following blogs:

(1) Why Putting Repositories in your pom is a bad idea

How to properly manage repository definitions and why you shouldn't declare them in your poms.

(2) Best Practices for Releasing with 3rd Party Snapshot Dependencies

How to most effectively create your own internal release of a snapshot dependency.

(3) Maven Continuous Integration Best Practices

Multiple techniques for running Maven builds from a CI system.

(4) How to Detect if you have a Snapshot Version

See the code that Maven uses to detect a snapshot version. This is helpful if you have non-standard release versions to make sure they won't be detected by Maven as a snapshot.

(5) Optimal Maven Plugin Configuration

Tips on how to configure plugins in a way that makes it easier to understand what is happening in your pom.

(6) Adding additional source folders to your Maven build

How to use the buildhelper plugin to add additional source folders to your build. This is common if you have tools that generate sources that don't have a Maven plugin to add the source folder automatically.

(7) Misused Maven Terms Defined

Find out about several terms that are often misquoted. This post also specifically discusses classifiers and attached artifacts.

(8) How to override a plugin's dependency

How to override a plugin dependency in your own pom...for example if you want to use a newer version of a tool wrapped by a plugin (pmd, checkstyle, cobertura are common examples)

(9) How to share resources across projects

How to share resources in a repeatable way without using relative paths in your poms. It also shows a technique for sharing checkstyle and pmd configurations across all your modules.

(10) How Plugin versions are determined

Learn about how Maven determines which version of a plugin to use, and why you should use PluginManagement to control the versions yourself.

(11) How to convert from Ant to Maven in 5 minutes

Okay so it might take longer than 5 minutes to convert from Ant to Maven, but this post will show you that it is possible to work the migration in parallel so that most of your team sees the conversion happen very quickly when the time is right.

(12) How to make an executable JAR

Step-by-step instructions on how to make a standalone JAR (i.e. one with no dependencies) executable.

 

Note: If you have suggestions for further topics, please leave a comment with your ideas.

Tags: Nexus Repo Reel, Sonatype Says, How-To, Maven best practices, Everything Open Source

Written by Brian Fox

Brian Fox is a software developer, innovator and entrepreneur. He is an active contributor within the open source development community, most prominently as a member of the Apache Software Foundation and former Chair of the Apache Maven project. As the CTO and co-founder of Sonatype, he is focused on building a platform for developers and DevOps professionals to build high-quality, secure applications with open source components.