#!/bin/sh BUNDLEURL=$1 GROUPID=$2 VERSION=$3 [ "${BUNDLEURL}" = "" ] && echo && echo "You must specify a bundle URL!" && echo && exit WORKDIR=bundle.tmp base=`basename $0` mylocation=`which $base` SCRIPTDIR=`dirname $mylocation` [ -d $SCRIPTDIR ] || SCRIPTDIR=. echo "Script directory is: ${SCRIPTDIR}" # repo dir relative to WORKDIR REPODIR=$HOME/repository-staging/to-ibiblio/maven REPO2DIR=$HOME/repository-staging/to-ibiblio/maven2 rm -rf $WORKDIR > /dev/null 2>&1 mkdir $WORKDIR cd $WORKDIR echo "Retrieving URL: '${BUNDLEURL}'" wget $BUNDLEURL BUNDLE=`echo $BUNDLEURL | sed -e 's#^.*/##;'` echo $BUNDLE mv $BUNDLE tmp.jar BUNDLE=tmp.jar ( echo "Unzipping original bundle." jar xf $BUNDLE || unzip $BUNDLE # copy files in subdirs to workdir echo "Copying files to working directory." for d in `find ./* -type d` ; do for f in `find $d -type f` ; do cp $f .; done; done echo "Searching for POM:" echo "...checking for 'project.xml'" POM=project.xml if [ ! -f ${POM} ] then echo "...checking for 'pom.xml'" POM=pom.xml fi if [ ! -f ${POM} ] then echo "...searching for **/*.pom" POM=`find . -iname *.pom` fi [ "" == "${POM}" ] && echo && echo "Cannot deploy without the pom.xml or project.xml file!" && echo && exit [ ! -f ${POM} ] && echo && echo "Cannot deploy without the pom.xml or project.xml file!" && echo && exit echo "POM is: '${POM}'" less $POM $SCRIPTDIR/d2u ${POM} if [ ! -z $VERSION ] then version=$VERSION else version=`cat ${POM} | tr '\n' ' ' | sed 's#.*##' | sed 's#.*##' | sed 's#.*##' | sed 's#.*##' | sed 's#.*##' | grep '' | sed -e 's#^.*##;s#.*$##'` if [ -z $version ] then version=`grep currentVersion ${POM} | sed -e 's#^.*##;s#.*$##'` fi fi artifactId=`cat ${POM} | tr '\n' ' ' | sed 's#.*##' | sed 's#.*##' | sed 's#.*##' | 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#.*##' | 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#.*##' | sed 's#.*##' | sed 's#.*##' | 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/ *$//'` groupDir=`echo ${groupId} | sed -e 's/\./\//g'` maven2=`cat ${POM} | grep ''` echo if [ ! -z "${maven2}" ] then echo " ========= MAVEN 2 ========= " fi echo echo " version: [${version}]" echo " groupId: [${groupId}]" echo "artifactId: [${artifactId}]" echo if [ -d $REPO2DIR/${groupDir} ] then echo "The group already exists" else echo "The group does NOT already exist" fi 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 if [ -f $LIC ] then $SCRIPTDIR/d2u $LIC mkdir -p $REPODIR/${groupId}/licenses cp -i $LIC $REPODIR/${groupId}/licenses/${artifactId}-${version}.license fi cp ${POM} ${artifactId}-${version}.pom m2dir=$REPO2DIR/${groupDir}/${artifactId}/${version} mkdir -p ${m2dir} mkdir -p $REPODIR/${groupId}/poms cp -i ${artifactId}-${version}.pom $REPODIR/${groupId}/poms if [ ! -z "${maven2}" ] then cp -i ${artifactId}-${version}.pom ${m2dir} md5sum ${m2dir}/${artifactId}-${version}.pom > ${m2dir}/${artifactId}-${version}.pom.md5 sha1sum ${m2dir}/${artifactId}-${version}.pom > ${m2dir}/${artifactId}-${version}.pom.sha1 fi 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 cp -i ${artifactId}-${version}.jar ${m2dir} if [ -f ${m2dir}/${artifactId}-${version}.jar ] then md5sum ${m2dir}/${artifactId}-${version}.jar > ${m2dir}/${artifactId}-${version}.jar.md5 sha1sum ${m2dir}/${artifactId}-${version}.jar > ${m2dir}/${artifactId}-${version}.jar.sha1 fi fi if [ -f ${artifactId}-${version}-sources.jar ] then echo "Deploying Java sources ..." mkdir -p $REPODIR/${groupId}/java-sources cp -i ${artifactId}-${version}-sources.jar $REPODIR/${groupId}/java-sources cp -i ${artifactId}-${version}-sources.jar ${m2dir} md5sum ${m2dir}/${artifactId}-${version}-sources.jar > ${m2dir}/${artifactId}-${version}-sources.jar.md5 sha1sum ${m2dir}/${artifactId}-${version}-sources.jar > ${m2dir}/${artifactId}-${version}-sources.jar.sha1 else echo "No Java sources available in upload bundle, skipping ..." fi if [ -f ${artifactId}-${version}-javadoc.jar ] then echo "Deploying Javadocs ..." mkdir -p $REPODIR/${groupId}/javadoc cp -i ${artifactId}-${version}-javadoc.jar $REPODIR/${groupId}/javadoc cp -i ${artifactId}-${version}-javadoc.jar ${m2dir} md5sum ${m2dir}/${artifactId}-${version}-javadoc.jar > ${m2dir}/${artifactId}-${version}-javadoc.jar.md5 sha1sum ${m2dir}/${artifactId}-${version}-javadoc.jar > ${m2dir}/${artifactId}-${version}-javadoc.jar.sha1 else echo "No Javadocs available in upload bundle, skipping ..." fi )