Strabon
view scripts/workaround/deploy-local-repo.sh @ 1552:0e334dc20181
bug in google maps key
author | Dimitris Bilidas <d.bilidas@di.uoa.gr> |
---|---|
date | Mon Nov 09 18:09:06 2020 +0200 (2020-11-09) |
parents | 8495c0c9b597 |
children |
line source
1 #!/bin/bash
3 #
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 #
8 # Copyright (C) 2010, 2011, 2012, Pyravlos Team
9 #
10 # http://www.strabon.di.uoa.gr/
11 #
13 #
14 # Script for deploying a local maven repository to a remote one
15 #
16 # Author: Kostis Kyzirakos <kk@di.uoa.gr>
17 #
20 # server id that maps on the <id> under <server> section of ~/.m2/settings.xml.
21 # In most cases, this parameter will be required for authentication.
22 DEPLOY_REPO_ID="strabon"
24 # the url of the remote repository
25 DEPLOY_REPO_URL="http://maven.strabon.di.uoa.gr/content/repositories/strabon.sesame/"
27 # temporary folder
28 TEMP_DIR="/tmp/deploy-local-repo-$$"
30 # command name
31 CMD="$(basename ${0})"
33 function help() {
34 echo "Usage: ${CMD} [OPTIONS] [DIR]"
35 echo
36 echo "Deploy a local maven repository to a remote one"
37 echo
38 echo " DIR : resume the deployment of the local repository, starting from this directory"
39 echo
40 echo "OPTIONS can be any of the following (variable names and values are case sensitive)"
41 echo " --help : Print this menu"
42 echo ""
43 }
45 if [[ ${#} -gt "0" ]] ; then
46 ARRAY=(${@})
47 ELEMENTS=${#ARRAY[@]}
48 for (( i = 0; i < ${ELEMENTS}; i++ )); do
49 if [[ "${ARRAY[${i}]}" = "--help" ]] || [[ "${ARRAY[${i}]}" = "-help" ]] || [[ "${ARRAY[${i}]}" = "help" ]]; then
50 help
51 exit 0
52 fi
53 done
54 fi
56 mkdir ${TEMP_DIR}
57 if [[ ! -d "${TEMP_DIR}" ]] ; then
58 echo "Could not create temporary directory."
59 echo "Aborting..."
60 exit
61 fi
63 found=false;
64 for d in `find ${HOME}/.m2/repository -type d|sort` ;
65 do
66 if [[ ! -z "$1" ]] && [[ "${found}" = "false" ]] && [[ "$d" != "$1" ]] ; then
67 echo "Skipping ${d}"
68 continue;
69 fi
70 # resuming
71 found=true;
73 #for each directory
74 cd ${d}
75 children=`find . -type d|grep -v '^.$'|wc -l`
76 if [[ "${children}" -ne "0" ]] ; then
77 # if the directory has more subdirectories, move one
78 continue;
79 fi
81 countPoms=`ls -1 *.pom 2>/dev/null|wc -l`
82 countJars=`ls -1 *.jar 2>/dev/null|wc -l`
84 if [[ "${countPoms}" -gt "1" ]] && [[ "${countJars}" -gt "1" ]] ; then
85 echo "Found ${countPoms} poms and ${countJars} jars in directory '${d}'."
86 echo "Aborting..."
87 exit;
88 elif [[ "${countPoms}" -eq "0" ]] ; then
89 echo "No .pom file found in directory '${d}' (${children} children)."
90 echo "Aborting..."
91 exit;
92 fi
94 if [[ "${countPoms}" -eq "1" ]] && [[ "${countJars}" -eq "1" ]] ; then
95 pomFile=`ls -1 *.pom 2>/dev/null`
96 jarFile=`ls -1 *.jar 2>/dev/null`
97 cp ${pomFile} ${TEMP_DIR}/${pomFile} 2>/dev/null
98 cp ${jarFile} ${TEMP_DIR}/${jarFile} 2>/dev/null
99 # deploy the local jar file to the remote repo
100 mvn deploy:deploy-file \
101 -DrepositoryId=${DEPLOY_REPO_ID} \
102 -Durl=${DEPLOY_REPO_URL} \
103 -DpomFile=${TEMP_DIR}/${pomFile} \
104 -Dfile=${TEMP_DIR}/${jarFile};
105 if [[ "$?" -ne "0" ]] ; then echo "Error occured while processing directory '${d}' (temp dir is '${TEMP_DIR}')"; exit; fi
106 elif [[ "${countPoms}" -eq "1" ]] && [[ "${countJars}" -eq "0" ]] ; then
107 pomFile=`ls -1 *.pom 2>/dev/null`
108 cp ${pomFile} ${TEMP_DIR}/${pomFile} 2>/dev/null
109 # deploy the local pom file to the remote repo
110 mvn deploy:deploy-file \
111 -DrepositoryId=${DEPLOY_REPO_ID} \
112 -Durl=${DEPLOY_REPO_URL} \
113 -DpomFile=${TEMP_DIR}/${pomFile} \
114 -Dfile=${TEMP_DIR}/${pomFile};
115 if [[ "$?" -ne "0" ]] ; then echo "Error occured while processing directory '${d}' (temp dir is '${TEMP_DIR}'"; exit; fi
116 elif [[ "${countPoms}" -gt "1" ]] && [[ "${countJars}" -eq "0" ]] ; then
117 # deploy the local pom files to the remote repo
118 for pom in `ls -1 *.pom` ; do
119 pomFile=${pom};
120 cp ${pomFile} ${TEMP_DIR}/${pomFile} 2>/dev/null;
121 mvn deploy:deploy-file \
122 -DrepositoryId=${DEPLOY_REPO_ID} \
123 -Durl=${DEPLOY_REPO_URL} \
124 -DpomFile=${TEMP_DIR}/${pomFile} \
125 -Dfile=${TEMP_DIR}/${pomFile};
126 if [[ "$?" -ne "0" ]] ; then echo "Error occured while processing directory '${d}' (temp dir is '${TEMP_DIR}'"; exit; fi
127 done
128 else
129 echo "Found ${countPoms} poms and ${countJars} jars in directory '${d}' (temp dir is '${TEMP_DIR}')."
130 echo "What should I do?"
131 echo "Aborting..."
132 exit;
133 fi
135 # grooming
136 rm ${TEMP_DIR}/*
137 done
140 # grooming
141 rm -rf ${TEMP_DIR}