views:

24

answers:

3

Our project has a dependency like

  <dependency>
    <groupId>apollo.components.cots</groupId>
    <artifactId>cots-wfs</artifactId>
  </dependency>

And as far as I understand, maven2 will get the latest artifact for cots-wfs, say <version>2.3-20101111.000000-13</version>

The problem is, when we branch the project, the dependency stays the same, and when other developers release a new cots-wfs say <version>2.3-20101222.000000-13</version> which is not backward compatible, the build is broken.

I am trying to avoid merging the code into the branch, which is painful.

So what do I need to do to "freeze" all the dependencies when I branch the project ? Is there any easy way to do this?

A: 

When you branch means in a sense you are creating a new version of it. Promoting the version number should solve it.

Teja Kantamneni
@Teja Kantamneni , which version number should be promoted? If i promote the version number of the artifact, the dependencies are still not frozen, meaning problem in building future release if developers release new stuffs
portoalet
A: 

Yeah just add the version tag to the dependency. If your unsure what the current version number is than run "mvn help:effective-pom" to see the pom with all current version numbers.

Mark Baijens
@Mark Baijens, so this means modifying the version tag for ALL dependencies?
portoalet
Or copy the entire effective pom is this is a lot of work for you. You might end up with some unneeded configuration this way.
Mark Baijens
+1  A: 

And as far as I understand, maven2 will get the latest artifact for cots-wfs, say <version>2.3-20101111.000000-13</version>

It looks like you are using a SNAPSHOT dependency for cots-wfs (2.3-SNAPSHOT), probably declared in the dependencyManagement section.

The problem is, when we branch the project, the dependency stays the same, and when other developers release a new cots-wfs (...) which is not backward compatible, the build is broken.

Indeed, which is why you should simply not branch an artifact with SNAPSHOT dependencies, the build of released artifacts should be reproducible, for ever, and using SNAPSHOT dependencies defeats this. The maven release plugin actually forbids releasing a POM having SNAPSHOT dependencies.

It is however possible to "lock" SNAPSHOT dependencies using versions:lock-snapshots or, even better, to use the corresponding released version using versions:use-releases. This is actually the way to go.

By the way, the Maven Release Plugin might help to automate the whole process.

Pascal Thivent
@Pascal Thanks for the input. I will use version:lock-snapshots. The problem with using released version is that it is very different to that of the latest as the code is evolving quickly. so I branch usually at the mainline.
portoalet