Monday, February 22, 2010

Google gdata library and maven

Despite a number of requests from a variety of users, there are as-yet no official maven versions of Google's gdata client Java library. There are various scripts to push the .jar files into a local repo, and one project on Google code containing an older version of the client library, mavenized. I think it's up to the code maintainers (Google) to put a process in place for pushing official maven versions of the gdata .jars out to the public repos. In the meantime, the best we can hope for is to load into local repos. However, a problem with the scripts I've seen is that they bake-in the various versions of the libraries to the script. So here's my variant, which takes the artifact name and version from the .jar filename:

#!/bin/bash

for f in java/lib/*.jar
do
  if [[ $f =~ java/lib/gdata-([a-z-]*)-(.*)\.jar ]]; then
      n=${BASH_REMATCH[1]}
      v=${BASH_REMATCH[2]}

      echo "installing mvn artifact $n $v"
      mvn install:install-file -DgroupId=com.google.gdata \
          -DartifactId=$n -Dversion=$v -Dfile=$f -Dpackaging=jar \
          -DgeneratePom=true
  fi
done

Tested on my Linux system at home, but I'm expecting this to also run on Windows/cygwin when I get into the office tomorrow!

Update Thanks to ildella on Twitter for pointing out that there's a maintained, up-to-date collection of maven-ized gdata artifacts on googlecode.

del.icio.us: maven, gdata,

2 comments:

pascal said...

Hello,
I have created a gdata maven repository stored on google code http://code.google.com/p/mandubian-mvn. I also added a Nexus Index to this repository and version up to 1.41.3 are currently mavenized!
Have fun!

Modified Bagel Car said...

If you are running archiva on your network you can tweak your script as follows:


#!/bin/bash

for f in java/lib/*.jar
do
if [[ $f =~ java/lib/gdata-([a-z-]*)-(.*)\.jar ]]; then
n=${BASH_REMATCH[1]}
v=${BASH_REMATCH[2]}

echo "deploying mvn artifact $n $v"
mvn deploy:deploy-file -DgroupId=com.google.gdata \
-DartifactId=$n -Dversion=$v -Dfile=$f -Dpackaging=jar \
-DgeneratePom=true \
-DrepositoryId=internal \
-Durl=http://yourarchivaserver:8080/archiva/repository/internal
fi
done