views:

608

answers:

2

There is a cruisecontrol plugin that checks for changes to snapshot dependencies, triggering a build if required. This involves using the Maven embedder to download the dependencies, then checking the timestamps of the snapshot files in the local repository. This works ok, but involves downloading all the parents and dependencies to check some timestamps.

I'm working on a distributed CI system (e.g. Bamboo/Buildforge) and would like to avoid downloading the entire dependency hierarchy to check if a build is required. It is possible to determine the build date of a snapshot dependency by checking the maven-metadata.xml on the remote repository.

Are there any plugins or tools to streamline this process?

+2  A: 

Assuming you're using maven as your build process, you want a plugin to do the checking and conditional build.

I don't know of any maven plugin that will do exactly what you want. However, you should be able cobble together a couple plugins for the same effect.

Use the exec plugin with "wget" to fetch the maven-metadata.xml. Then use the xslt plugin to transform the resulting XML into a boolean value that will indicate whether or not an update has occured. You'll want to XPath to the //metadata/versioning/lastUpdated node and compare it to the current date and time. Finally, you'll need to examine the resulting transformed XML to determine if you should proceed with the build.

Find those plugins at http://mojo.codehaus.org/plugins.html

nont
I know I can cobble it together, and have. I am looking for a library, utility, or something that avoids the need for the hacking
Rich Seller
+1  A: 

It looks like Mercury provides the higher level API I was looking for.

Mercury provides an implementation-neutral way to access GAV-based repositories, including AV repositories, like OSGi. OSGi access is not implemented yet. By access I mean reading artifacts and metadata from repositories and writing artifacts to repositories, metadata is updated by writes.

All the calls accept a collection of requests as an input and return an object that hides getResults, that normally is a map< queryElement, Collection > response. The response object has convenience methos hasExceptions(), hasResults(), getExceptions(), getResults()

One of the key building blocks is a hierarchy of Artifact data:

  • ArtifactCoordinates - is truly the 3 components GAV
    • ArtifactBasicMetadata - is coordinates plus type/classifier plus convenience methods like hash calculation and such
  • ArtifactMetadata adds a list of dependency objects, captured as ArtifactBasicMetadata
  • DefaultArtifact implements Artifact interface and adds pomBlob (byte[]) and file, that points to actual binary
Rich Seller