Tuesday, April 28, 2009

Dependency Version Ranges

You can specify a range of versions that would satisfy a given dependency.

For example, if you wished to access any JUnit version greater than or equal to 3.8 but less than 4.0

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>[3.8,4.0)</version>
<scope>test</scope>
</dependency>


If you want to depend on any version of JUnit no higher than 3.8.1



<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>[,3.8.1]</version>
<scope>test</scope>
</dependency>


A version before or after the comma is not required, and means +/- infinity. For example, "[4.0,)" means any version greater than or equal to 4.0. "(,2.0)" is any version less than 2.0. "[1.2]" means only version 1.2, and nothing else.

No comments:

Post a Comment