A criticism I hear often about Maven is, “every time you run Maven, it downloads the internet.” I understand the criticism, as the first time you run Maven it has to populate your local repository. Maven downloads plugins and artifacts that your project depends on. Maven does in fact download artifacts from remote repositories, but it downloads the artifact once and keeps a local cache.
Maven only downloads most of these dependencies because you’ve added them to your project. If you are unhappy that Maven is “downloading the internet” then stop developing software that depends on external libraries. Easy, right? Stop using Spring and Hibernate, stop referencing the commons libraries, and do everything yourself. This would be one way to avoid downloading any artifacts from a remote repository. Stop using Maven to build your software and write your own build tool that has all of the capabilities of Maven and every imaginable Maven plugin baked into it.
Not a workable solution, right? The fact of the matter is that your software has dependencies on external libraries. If you find yourself constantly “downloading the internet” there’s a reason. You are depending on projects that depend on “the internet” or, your projects have a very wide set of dependencies that may need to be trimmed.
How can we avoid creating projects and POMs that “download the internet”? The simple answer is that everyone needs to start focusing on dependencies. Library developers need to be smarter about creating leaner, meaner dependency lists, and you need to start evaluating your own dependencies with an eye on efficiency.
If you use the m2eclipse POM XML editor, you will be interested to know that we’ve made a number of improvements to the interface. Yesterday, we introduced some addition auto-correct options and automatic integration of the POM XML editor and the Artifact Search dialog. Today, we focus on improved navigation options now available in the m2eclipse POM XML Editor. By making use of the current effective POM, we are able to give you more information right at your fingertips.
The screenshot below shows options that are available to you by hovering over on an expression in the m2eclipse POM XML Editor.
In the upcoming m2eclipse release, we’ve reworked how inserting artifacts (dependencies, plugins, parents) works in the XML editor. Instead of generating a skeleton template snippet for you to populate with maven coordinates (groupId/artifactId/version) we reuse the Artifact Search dialog. This post is a glimpse into some of the functionality that will be available in the coming weeks.
Instead of expecting a user to supply these artifacts directly in the XML editor, you now have the option to search for an artifact and let m2eclipse take care of the details. We’ve also made some improvements to the Artifact Search dialog. Screenshots speak as thousands of words though so let’s take a look.
Read the rest of this post to learn more about this new way to insert artifact coordinates in a Maven POM using m2eclipse.
In projects with many parent POMs, profiles, and plugin management sections, one can easily end up in a situation where the effective configuration for a plugin is the result of merging many configuration blocks from the various POM sources together.
Not knowing the details of this merge process naturally leads to some confusion about why an effective configuration looks the way it looks, or why changes to some parent POM’s configuration don’t have the desired effects in child POMs.
This post attempts to shed some light on this confusion, and provides you with a sense of how Maven merges plugin configuration from multiple sources. This post uses attributes which are available in Maven 3.0.2.
You’ve completed Maven 101, learned about the Maven lifecycle, Maven plugins, goals and projects, all about the contents of the Project Object Model (POM) – so what’s next?
For those wanting to dive even deeper into Maven, Sonatype is offering an online training course, Maven 201: Development Infrastructure Design.
Maven 201 covers advanced topics such as:
- Advanced multimodule project architecture
- Enforcing standards with the Enforcer plugin
- Installing and configuring a repository manager
- Installing and configuring a continuous integration server
At the end of this training course, you will have advanced familiarity with the structure of a Maven POM and a Maven multi-module project.
Next training course:
- January 20 & 21, 2011
- 11:00 am – 4:00 pm EST (GMT – 05:00)
- Enroll today