Section 1.9. Depending on Snapshots


1.9. Depending on Snapshots

If you are developing a program that depends on a frequently changing dependency, you might want to depend on the latest build instead of hardcoding a version for each dependency. This can be especially useful when a project depends on a dependency which is still a beta of a release candidate, or if you are developing a series of interdependent Maven projects, as discussed in Chapter 3. In this lab, you'll learn how to depend on a SNAPSHOT.

1.9.1. How do I do that?

Instead of specifying a specific version in your dependency block, use the keyword SNAPSHOT as part of the version name. Every time you execute a Maven goal, Maven will check for a new version of the dependency from the remote repository. Maven will download the dependency if the remote repository has a newer version than the local repository. For example, the following dependency would always download the latest 1.2 development JAR of spring:

<dependency>   <groupId>springframework</groupId>   <artifactId>spring</artifactId>   <version>1.2-SNAPSHOT</version> </dependency>

1.9.2. What just happened?

When you use SNAPSHOT dependencies you are telling Maven to use the latest version in the remote repository. This will come in handy when you are using the Multiproject plug-in, or when you are depending on an artifact still in development, as will often be the case if you're working on a team consisting of more than a few developers. You will be using SNAPSHOT dependencies when your project depends on the latest development or unreleased version of a particular component. SNAPSHOT dependencies should be reserved for development purposes, and, as a rule, you should never release a project that depends on a SNAPSHOT dependency.


Note: Maven 2 increases the configurability of the SNAPSHOT dependency mechanism. The next release will allow you to specify how often Maven checks for an updated SNAPSHOT release.


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