#!/bin/sh
BUNDLEURL=$1
GROUPID=$2
VERSION=$3
[ "${BUNDLEURL}" = "" ] && echo && echo "You must specify a bundle URL!" && echo && exit
WORKDIR=bundle.tmp
# repo dir relative to WORKDIR
REPODIR=$HOME/repository-staging/to-ibiblio/maven
rm -rf $WORKDIR > /dev/null 2>&1
mkdir $WORKDIR
cd $WORKDIR
wget $BUNDLEURL
BUNDLE=`echo $BUNDLEURL | sed -e 's#^.*/##;'`
echo $BUNDLE
(
jar xf $BUNDLE
# copy files in subdirs to workdir
for d in `find ./* -type d` ; do
for f in `find $d -type f` ; do cp $f .; done;
done
POM=project.xml
less $POM
../d2u ${POM}
[ ! -f ${POM} ] && echo && echo "Cannot deploy without the project.xml file!" && echo && exit
if [ ! -z $VERSION ]
then
version=$VERSION
else
version=`cat ${POM} | tr '\n' ' ' | sed 's#.*##' | sed 's#.*##' | grep '' | sed -e 's#^.*##;s#.*$##'`
if [ -z $version ]
then
version=`grep currentVersion ${POM} | sed -e 's/^ *//;s///;s/<\/currentVersion>//'`
fi
fi
artifactId=`cat ${POM} | tr '\n' ' ' | sed 's#.*##' | sed 's#.*##' | sed 's#.*##' | grep '' | sed -e 's#^.*##;s#.*$##'`
if [ -z $artifactId ]
then
artifactId=`cat ${POM} | tr '\n' ' ' | sed 's#.*##' | sed 's#.*##' | sed 's#.*##' | sed 's#.*##' | grep '' | sed -e 's#^.*##;s#.*$##'`
fi
if [ ! -z $GROUPID ]
then
groupId=${GROUPID}
else
groupId=`cat ${POM} | tr '\n' ' ' | sed 's#.*##' | grep '' | sed -e 's#^.*##;s#.*$##'`
if [ -z $groupId ]
then
groupId=${artifactId}
fi
fi
version=`echo ${version} | sed -e 's/ *$//'`
artifactId=`echo ${artifactId} | sed -e 's/ *$//'`
groupId=`echo ${groupId} | sed -e 's/ *$//'`
echo
echo " version: [${version}]"
echo " groupId: [${groupId}]"
echo "artifactId: [${artifactId}]"
echo
echo
echo -n Hit Enter to continue or Ctrl-C to abort...
read
LIC=LICENSE.txt
# A little help for manually created upload bundles
[ -f license.txt ] && mv license.txt $LIC
[ -f licence.txt ] && mv licence.txt $LIC
[ ! -f $LIC ] && echo && echo "Cannot deploy without the $LIC file!" && echo && exit
cp project.xml ${artifactId}-${version}.pom
../d2u $LIC
mkdir -p $REPODIR/${groupId}/licenses
cp -i $LIC $REPODIR/${groupId}/licenses/${artifactId}-${version}.license
mkdir -p $REPODIR/${groupId}/poms
cp -i ${artifactId}-${version}.pom $REPODIR/${groupId}/poms
artifactType=`echo ${artifactId} | sed -e 's/maven-.*-plugin//'`
if [ -z ${artifactType} ]
then
echo "Deploying Plugin ..."
mkdir -p $REPODIR/${groupId}/plugins
cp -i ${artifactId}-${version}.jar $REPODIR/${groupId}/plugins
else
echo "Deploying JAR ..."
mkdir -p $REPODIR/${groupId}/jars
cp -i ${artifactId}-${version}.jar $REPODIR/${groupId}/jars
fi
)