We create a search index for the Maven repository so that you don’t have to. What does this mean for you? It means that you don’t have to run a “little Google” in your datacenter just to search for the latest log4j library, and you also don’t have to sacrifice Terabytes of bandwidth to download thousands of artifacts you’ll never use to just to find the handful you need for your project. This is all done for you on Central, and the tools you use to search Central, Nexus and m2eclipse all benefit from this pre-made index file.
While this seems like such a simple idea, the Maven ecosystem hasn’t had a standard way to search the repository for the majority of its history. For much of the last decade there was no reliable way to search for an artifact. In this post, I’m going to review this history and talk about Maven repository search and where we think search is headed. With the release of Nexus OSS 1.9 it is now a good time to summarize the results of Sonatype donation of the Nexus Indexer to the Apache Software Foundation.
I almost called this post a Maven “Pet Peeve”, but I’ll stick with “Tip” (and I’ll keep it brief). Here’s a new rule, and I’d really like to hear what the community thinks about this.
Here’s the rule:
Name your project’s directory after the artifactId of your project. It is much easier for everyone to quickly recognize and comprehend multi-module project structure, and it will more closely resemble the experience for developers working with IDEs.
Why do this?
Because it leads to simpler, easier to understand project structure. Some of you might be reading this and asking why we need to remind people of such an obvious rule. Others might take issue with the proposed rule, but I’ll try to detail why I think it is so important. Take the following collection of projects as an example:
Which one do you prefer? Left or right, and why?
On the one hand it is less typing for people on the command line to use simple directory names for Maven modules.
But, on the other hand, if you import these projects with m2eclipse you are going to end up with projects named after the artifactId. The same is true if you import these projects into IntelliJ.
I would suggest always opting for the option on the right. It is clearer than the alternative, and requires less hands-on investigation to track down a culprit project if you are debugging build errors.
An Important Note from Brian Fox: Naming the folder after the artifactId is critical if you expect inherited urls (scm/site) to work. It always appends the artifactId to the url as it’s inherited. And for the same reason, you want them to match what’s in the scm.
When should the code be tagged? How is the release/branch/tag process related to deployment? How should we branch during the release process? Should we branch early on in the release? Or, should we just continue on in trunk and only branch when we need to start parallel development? Who performs the release and from what machine? Do we run this plugin from Hudson?
This is a sample of some of the questions I’ve been asked by customers over the past few years, and, believe it or not, my answers are always a little less than satisfying. My stock answer to one of these questions is along the lines of: Well, Maven has a certain set of opinions about how you should manage releases, but it isn’t set in stone and there are as many variations in a project’s release process as there are corporations that code Java.
What we call “The Release Process” is seldom simply a technology problem and more than often involves process, organizational structure, and definitions of responsibilities. These are the intangibles that lead to the reality: everyone’s “Release Process” tends to be unique, especially as your projects become more important and more complex.
You’ve probably heard that Sonatype teaches a series of online Maven training classes. They are a great way to get you and your team up and running on Maven, and if you have any specific questions we also make sure to leave some space in the class to answer any questions you might have. In my experience, the students that get the most from our classes are the students that ask questions.
In this post, I answer some of the questions that came up in our last training session.
There has been an incredible demand for Sonatype’s Maven training courses lately. You asked for more and we answered – We’ve opened up additional seats for our February training dates. Register today before your seat is taken!
Available training courses: