Strabon

changeset 1044:f266f9932ce4

Fixed some issues.
author Kostis Kyzirakos <kkyzir@di.uoa.gr>
date Thu Apr 18 18:35:04 2013 +0300 (2013-04-18)
parents 989e5948ea23
children 9b34e404bcaf
files scripts/workaround/deploy-local-repo.sh
line diff
     1.1 --- a/scripts/workaround/deploy-local-repo.sh	Thu Apr 18 15:43:16 2013 +0300
     1.2 +++ b/scripts/workaround/deploy-local-repo.sh	Thu Apr 18 18:35:04 2013 +0300
     1.3 @@ -1,9 +1,58 @@
     1.4  #!/bin/bash
     1.5 -# check your ~/.m2/settings.xml for the correct values
     1.6 -DEPLOY_REPO_ID="strabon.testing"
     1.7 -DEPLOY_REPO_URL="http://maven.strabon.di.uoa.gr/content/repositories/testing/"
     1.8 +
     1.9 +#
    1.10 +# This Source Code Form is subject to the terms of the Mozilla Public
    1.11 +# License, v. 2.0. If a copy of the MPL was not distributed with this
    1.12 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
    1.13 +#
    1.14 +# Copyright (C) 2010, 2011, 2012, Pyravlos Team
    1.15 +#
    1.16 +# http://www.strabon.di.uoa.gr/
    1.17 +#
    1.18 +
    1.19 +#
    1.20 +# Script for deploying a local maven repository to a remote one
    1.21 +#
    1.22 +# Author: Kostis Kyzirakos <kk@di.uoa.gr>
    1.23 +#
    1.24 +
    1.25 +
    1.26 +# server id that maps on the <id> under <server> section of ~/.m2/settings.xml.
    1.27 +# In most cases, this parameter will be required for authentication.
    1.28 +DEPLOY_REPO_ID="strabon"
    1.29 +
    1.30 +# the url of the remote repository
    1.31 +DEPLOY_REPO_URL="http://maven.strabon.di.uoa.gr/content/repositories/strabon.sesame/"
    1.32 +
    1.33 +# temporary folder
    1.34  TEMP_DIR="/tmp/deploy-local-repo-$$"
    1.35  
    1.36 +# command name
    1.37 +CMD="$(basename ${0})"
    1.38 +
    1.39 +function help() {
    1.40 +        echo "Usage: ${CMD} [OPTIONS] [DIR]"
    1.41 +        echo
    1.42 +        echo "Deploy a local maven repository to a remote one"
    1.43 +        echo
    1.44 +        echo "  DIR     : resume the deployment of the local repository, starting from this directory"
    1.45 +        echo
    1.46 +        echo "OPTIONS can be any of the following (variable names and values are case sensitive)"
    1.47 +        echo "  --help           : Print this menu"
    1.48 +		echo ""
    1.49 +}
    1.50 +
    1.51 +if [[ ${#} -gt "0" ]] ; then
    1.52 +	ARRAY=(${@})
    1.53 +	ELEMENTS=${#ARRAY[@]}
    1.54 +	for (( i = 0; i < ${ELEMENTS}; i++ )); do
    1.55 +		if [[ "${ARRAY[${i}]}" = "--help" ]] || [[ "${ARRAY[${i}]}" = "-help" ]] || [[ "${ARRAY[${i}]}" = "help" ]]; then
    1.56 +			help
    1.57 +			exit 0
    1.58 +		fi
    1.59 +	done
    1.60 +fi
    1.61 +
    1.62  mkdir ${TEMP_DIR}
    1.63  if [[ ! -d "${TEMP_DIR}" ]] ; then
    1.64  	echo "Could not create temporary directory."
    1.65 @@ -11,70 +60,78 @@
    1.66  	exit
    1.67  fi
    1.68  
    1.69 +found=false;
    1.70 +for d in `find ${HOME}/.m2/repository -type d|sort` ;
    1.71 +do
    1.72 +	if [[ ! -z "$1" ]] && [[ "${found}" = "false" ]] && [[ "$d" != "$1" ]] ; then
    1.73 +		echo "Skipping ${d}"
    1.74 +		continue;
    1.75 +	fi
    1.76 +	# resuming
    1.77 +	found=true;
    1.78  
    1.79 -for d in `find ${HOME}/.m2/repository -type d` ;
    1.80 -do
    1.81  	#for each directory
    1.82  	cd ${d}
    1.83 -	children=`find . -type d|wc -l`
    1.84 -	if [[ "${children}" -ne "1" ]] ; then
    1.85 +	children=`find . -type d|grep -v '^.$'|wc -l`
    1.86 +	if [[ "${children}" -ne "0" ]] ; then
    1.87  		# if the directory has more subdirectories, move one
    1.88  		continue;
    1.89  	fi
    1.90  
    1.91  	countPoms=`ls -1 *.pom 2>/dev/null|wc -l`
    1.92 -	countJars=`ls -1 *.pom 2>/dev/null|wc -l`
    1.93 +	countJars=`ls -1 *.jar 2>/dev/null|wc -l`
    1.94  
    1.95  	if [[ "${countPoms}" -gt "1" ]] && [[ "${countJars}" -gt "1" ]] ; then
    1.96  		echo "Found ${countPoms} poms and ${countJars} jars in directory '${d}'."
    1.97  		echo "Aborting..."
    1.98  		exit;
    1.99  	elif [[ "${countPoms}" -eq "0" ]] ; then
   1.100 -		echo "No .pom file found in directory '${d}'."
   1.101 +		echo "No .pom file found in directory '${d}' (${children} children)."
   1.102  		echo "Aborting..."
   1.103  		exit;
   1.104  	fi
   1.105  
   1.106 -	pomFile=`ls -1 *.pom 2>/dev/null`
   1.107 -	jarFile=`ls -1 *.jar 2>/dev/null`
   1.108 -	cp ${pomFile} ${TEMP_DIR}/${pomFile} 2>/dev/null
   1.109 -	cp ${jarFile} ${TEMP_DIR}/${jarFile} 2>/dev/null
   1.110 -
   1.111 -
   1.112  	if [[ "${countPoms}" -eq "1" ]] && [[ "${countJars}" -eq "1" ]] ; then
   1.113 +		pomFile=`ls -1 *.pom 2>/dev/null`
   1.114 +		jarFile=`ls -1 *.jar 2>/dev/null`
   1.115 +		cp ${pomFile} ${TEMP_DIR}/${pomFile} 2>/dev/null
   1.116 +		cp ${jarFile} ${TEMP_DIR}/${jarFile} 2>/dev/null
   1.117  		# deploy the local jar file to the remote repo
   1.118  		mvn deploy:deploy-file \
   1.119  			-DrepositoryId=${DEPLOY_REPO_ID} \
   1.120  			-Durl=${DEPLOY_REPO_URL} \
   1.121  			-DpomFile=${TEMP_DIR}/${pomFile} \
   1.122  			-Dfile=${TEMP_DIR}/${jarFile};
   1.123 +		if [[ "$?" -ne "0" ]] ; then echo "Error occured while processing directory '${d}' (temp dir is '${TEMP_DIR}')"; exit; fi
   1.124  	elif [[ "${countPoms}" -eq "1" ]] && [[ "${countJars}" -eq "0" ]] ; then
   1.125 +		pomFile=`ls -1 *.pom 2>/dev/null`
   1.126 +		cp ${pomFile} ${TEMP_DIR}/${pomFile} 2>/dev/null
   1.127  		# deploy the local pom file to the remote repo
   1.128  		mvn deploy:deploy-file \
   1.129  			-DrepositoryId=${DEPLOY_REPO_ID} \
   1.130  			-Durl=${DEPLOY_REPO_URL} \
   1.131  			-DpomFile=${TEMP_DIR}/${pomFile} \
   1.132  			-Dfile=${TEMP_DIR}/${pomFile};
   1.133 +		if [[ "$?" -ne "0" ]] ; then echo "Error occured while processing directory '${d}' (temp dir is '${TEMP_DIR}'"; exit; fi
   1.134 +	elif [[ "${countPoms}" -gt "1" ]] && [[ "${countJars}" -eq "0" ]] ; then
   1.135 +		# deploy the local pom files to the remote repo
   1.136 +		for pom in `ls -1 *.pom` ; do
   1.137 +			pomFile=${pom};
   1.138 +			cp ${pomFile} ${TEMP_DIR}/${pomFile} 2>/dev/null;
   1.139 +			mvn deploy:deploy-file \
   1.140 +				-DrepositoryId=${DEPLOY_REPO_ID} \
   1.141 +				-Durl=${DEPLOY_REPO_URL} \
   1.142 +				-DpomFile=${TEMP_DIR}/${pomFile} \
   1.143 +				-Dfile=${TEMP_DIR}/${pomFile};
   1.144 +			if [[ "$?" -ne "0" ]] ; then echo "Error occured while processing directory '${d}' (temp dir is '${TEMP_DIR}'"; exit; fi
   1.145 +		done
   1.146  	else
   1.147 -		echo "Found ${countPoms} poms and ${countJars} jars in directory '${d}'."
   1.148 +		echo "Found ${countPoms} poms and ${countJars} jars in directory '${d}' (temp dir is '${TEMP_DIR}')."
   1.149  		echo "What should I do?"
   1.150  		echo "Aborting..."
   1.151  		exit;
   1.152  	fi
   1.153  
   1.154 -	pomFile=`ls -1 *.pom`
   1.155 -	jarFile=`ls -1 *.jar`
   1.156 -
   1.157 -	cp ${pomFile} ${TEMP_DIR}/${pomFile}
   1.158 -	cp ${jarFile} ${TEMP_DIR}/${jarFile}
   1.159 -
   1.160 -	# deploy the local file to the remote repo
   1.161 -	mvn deploy:deploy-file \
   1.162 -		-DrepositoryId=${DEPLOY_REPO_ID} \
   1.163 -		-Durl=${DEPLOY_REPO_URL} \
   1.164 -		-DpomFile=${TEMP_DIR}/${pomFile} \
   1.165 -		-Dfile=${TEMP_DIR}/${jarFile};
   1.166 -
   1.167  	# grooming
   1.168  	rm ${TEMP_DIR}/*
   1.169  done