Using embedded repositories to ease Maven migrations

Published: 11:01 PM GMT+12, Sunday, 20 January 2008 under: technology
java  maven  dependency 

For awhile I've been wanting to explore migrating our build platform from Apache Ant to Apache Maven and taking advantage of dependency management, the release plugin, and a standardized build process.

One problem I always seem to hit whenever I start to look at mavenizing things - library X version Y that we use is not in the standard repository. The simple solution is to just install the file to my local repository, or a standalone repository for the company to use - the former works great "for me", and the later requires some infrastructure setup (nothing major, but more than my lazy experimenter mind can currently be bothered with).

However, an insanely simple, blindingly obvious solution came to mind - convert/refactor your ./libs directory structure into a repository and declare thus:

<repositories>
  <repository>
    <id>local.3rd.party</id>
    <name>Local 3rd Party repo</name>
    <url>file://${basedir}/repo/</url>
  </repository>
</repositories>

By adding this to your maven pom.xml your simply declaring a local repository thats checked out with your code. Not only can you now easily use maven with your existing libraries, you're ./lib directory is now structured rather than a flat jar dump that often gets slapped into the source tree.

As we're using subversion, we could easily extend this with Subversion's Externals and keep the jars separate from your projects source and share them over multiple projects, or better yet - we could just use Maven's wagon-scm plugin and simply use the subversion repository as a maven repository.

Comments (0)

Add Comment