Friday, July 13, 2007

Maven local repository synchronization

We extensively use maven for building our software. The reason behind it is the fact that maven manages inter project dependencies very effectively and efficiently. Another reason is the Repositories in maven, this helps individuals to grab the third party dependent jars from a single place and then use them in their favorite IDE. However very often you will find that local repository that maven maintains (usually under <user.home>/.m2/repository folder) is not in sync with the remote repository. I tried to find out a solution for this problem which lead me to two projects being developed and maintained by codehaus.
  1. MaveIde
  2. Maven Integration for Eclipse
However none of them was particularly useful. They are still under development and buggy. What I found then was a simple solution in the from of ant task. Again this solution is itself available from Maven at http://maven.apache.org/download.html. Here is a small ant script snippet which demonstrate the usage of these ant task(s) to synchronize your local repository.
<target name="pomcheck">
    <echo message="Runnint POM check."/>
    <dependencies verbose="true"
        settingsfile="${user.home}/.m2/settings.xml"
        filesetId="maven-ant-tasks.dependency.fileset"
        profiles="default, MavenCentral">
        <dependency groupid="product" artifactid="core"
            version="1.5.5.1"/>
        <remoterepository id="maven_global"
            url="http://maven.company.com/mavenrepo/global"/>
        <remoterepository id="maven_released"
            url="http://maven.company.com/mavenrepo/released"/>
        <remoterepository id="maven-snaps"
            url="http://maven.company.com/mavenrepo/snapshots"/>
        <remoterepository id="MavenCentral"
            url="http://repo1.maven.org/maven2"/>
    </dependencies>
</target>
That's it folks. Tomorrow we will dive into details of the above ant scripts. I will show you how to configure eclipse to run this script and meaning of each of the tag.

2 comments:

Unknown said...

raven mahit hota.. maven kay ahe re bhau..

Salil

BizSutra Designer said...

Ravan Ramayana madhye hota. Maven Java (Adhunik Ramayana) madhye aahe!

Disclaimer: The views expressed in this blog are my own and do not necessarily reflect the views of any former, current or future employers or employees of mine