Skip to content

A script to add 3rd party artifacts to your maven repository

April 22, 2008

I find the maven command line very obtuse and have trouble remembering the right incantation to add 3rd party jars to a local repository.

Here is a small bash script which might be useful to others. You will need to edit this for your environment.

#!/bin/bash
# Add 3rd party jars to maven in a batch
# Usage: madd groupid version jar1 jar2 ...
#
# Edit the mvn command as per your repo setup

if [ $# -lt 3 ]; then
echo Usage: $0 groupid version jar1 jar2...
exit 1
fi

GROUPID=$1
shift
VERSION=$1
shift

for file in $*
do
ARTIFACTID=`echo $file | sed -e 's/\.jar//'`
mvn deploy:deploy-file -DgroupId=$GROUPID -DartifactId=$ARTIFACTID \
-Dversion=$VERSION -Dpackaging=jar -Dfile=$file \
-Durl=http://localhost:8081/nexus/content/repositories/thirdparty \
-DrepositoryId=thirdparty
done

Advertisements

Comments are closed.

%d bloggers like this: