In Part 1 of this post, I covered performing a basic installation of Nexus in a Tomcat servlet container on Ubuntu 11.10. Now I’m going to cover the details of configuring Nexus.
- Storing Versions of My Own Artifacts – I try to do all my Java builds in Maven these days. This means that all my projects always have a standard lifecycle and release procedures. I can commit my code to SVN, but its also nice to have a repository to store my compiled artifacts. Nexus fills this job, allowing me to deploy all versioned projects to the central repository, accessible from all of my machines. Additionally, the repository makes all these versioned artifacts available as dependencies for any of the other projects I work with.
- Proxying Other Repositories – When you work with Java Maven projects, you’ll get pretty used to Maven “downloading the internet” the first time you build a particular project on a machine. This is Maven getting all the dependencies and transitive dependencies required to build your project. It might take a little while, but its far better than trying to manage all those dependencies yourself. This step is often dependent on external repositories outside of my control, however. The external repositories may gone down (but rarely), and it is common for these repositories to eventually remove old versions of artifacts or reorganize their repositories. Proxying a repository means that my Maven builds will always fetch artifacts from my Nexus repository first. If Nexus can’t find the artifact, it will download it from the external repository, but it will store it locally so future requests do not depend on the external repository. This means that the artifacts I use never go away, and the process is much faster since I only need to retrieve artifacts from my own repository in most cases.
- Hosting 3rd Party Artifacts – There are times when I use a jar, but the jar isn’t readily available in a Maven repository somewhere. I try to avoid just adding those jars to SVN. Instead, I’ll upload the artifacts to Nexus and I can access them as needed via standard Maven builds.