Saturday, 2 July 2011

Using Version Numbers in POM Files.

A top tip: when you have a POM file or set of POM files that reference a bunch of libraries that have the same version number, then it’s a good idea to setup a version property. To do this, add the following near the top of a parent POM:

<properties>
  <spring.version>3.0.5.RELEASE</spring.version>
 </properties> 

and then use the ${} to set up the Maven JAR version number:

<dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
       etc...

As you can see, this works especially well for Spring and is is obviously much better than setting them all individually...

<dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>3.0.5.RELEASE</version>
        </dependency>
        etc...

No comments: