Section 5.1. Sharing a Maven Installation


5.1. Sharing a Maven Installation

When you're working on a team, it's a good idea to use a common development environment. This way you don't have to constantly struggle to figure out why something that works on your machine doesn't work on that of a colleague. A common development environment also makes it easier to upgrade dependencies and add new features to your shared build and test systems. A common challenge in large workgroups is standardizing on a central build system, and in this lab, you will discover how to share a Maven installation on a development team.

5.1.1. How do I do that?

The first thing to do is to unpack the Maven installation files and place them in a location accessible by everyone. Typically, this can be either a shared drive or an SCM system (in the latter case developers will need to check out the Maven files). A good practice is to make this shared Maven installation read-only; this makes it impossible for developers to introduce errors into files not intended for modification. Let's assume that you now have access to the shared Maven installation files from the c:\apps\maven directory on a Windows machine, or from the /usr/local/maven directory in a Unix environment (you can pick any directory you like).

Now, set your MAVEN_HOME environment variable to point to c:\apps\maven (or /usr/local/maven on Unix) and have your PATH environment variable point to MAVEN_HOME/bin. Figure 5-1 shows a Maven installation shared between two usersVincent and Tim.

Figure 5-1. Sharing a Maven installation between two development members (Vincent and Tim)


5.1.2. What just happened?

You have just shared a Maven installation. The core Maven files are the same ones used by everyone, and all your user-specific local Maven files are located on your machine in a .maven directory located in your home directory. Your .maven directory contains the following subdirectories:

  • The cache/ directory, which contains all the Maven plug-ins found in MAVEN_HOME/plugins in expanded format (they are JAR files). You can safely delete this directory, and Maven will re-create it at the next run.

  • The plugins/ directory, which is the user plug-in directory. Maven does not create this directory automatically. You can create it if you need to use custom plug-ins. Any JAR plug-in that you drop in this directory will be expanded by Maven in the cache/ directory. Note that in the case of a version conflict, the plug-ins in this plugins/ directory take precedence over the plug-ins in MAVEN_HOME/plugins. Using the plugins/ directory is a good way to customize a read-only Maven installation.

  • The repository/ directory, which was explained in Section 1.1. This directory is your local Maven repository and it contains all the artifacts that are cached locally on your machine.


Note: In Maven 2 there's no longer a notion of unpacking plug-in JARs, nor of a cache directory. Plug-ins are accessed directly from the repository.


Maven. A Developer's Notebook
Maven: A Developers Notebook (Developers Notebooks)
ISBN: 0596007507
EAN: 2147483647
Year: 2003
Pages: 125

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net