| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Gant -- A Groovy way of scripting Ant tasks. |
| 4 |
# |
| 5 |
# Copyright © 2006–2010, 2013 Russel Winder |
| 6 |
# |
| 7 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 8 |
# compliance with the License. You may obtain a copy of the License at |
| 9 |
# |
| 10 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
# |
| 12 |
# Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 13 |
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 14 |
# implied. See the License for the specific language governing permissions and limitations under the |
| 15 |
# License. |
| 16 |
# |
| 17 |
# Author : Russel Winder <[email protected]> |
| 18 |
|
| 19 |
# Gant initiation script for Linux and UNIX -- requires Groovy version. |
| 20 |
|
| 21 |
# Solaris 10 does not have readlink as standard -- though some people will have the version from |
| 22 |
# Sunfreeware which is the same as the version on Ubuntu, Cygwin, MSYS, etc. Mac OS X has a version of |
| 23 |
# readlink that is very different to that on Ubuntu, Solaris/Sunfreeware, Cygwin, MSYS, etc. |
| 24 |
# |
| 25 |
# This function attempts to just do the right thing. |
| 26 |
|
| 27 |
doReadLink() { |
| 28 |
case `uname` in |
| 29 |
Darwin) |
| 30 |
gantLocation=`dirname $1` |
| 31 |
gantPath=`readlink "$1"` |
| 32 |
if [ "$gantPath" = "" ] |
| 33 |
then |
| 34 |
readlinkValue="$1" |
| 35 |
else |
| 36 |
linkDir=`dirname $gantPath` |
| 37 |
currentDirectory=`pwd` |
| 38 |
cd $gantLocation |
| 39 |
cd $linkDir |
| 40 |
gantLocation=`pwd` |
| 41 |
gantPath=`basename $gantPath` |
| 42 |
readlinkValue="$gantLocation/$gantPath" |
| 43 |
cd $currentDirectory |
| 44 |
fi |
| 45 |
;; |
| 46 |
SunOS) |
| 47 |
readlinkPath=`which readlink` |
| 48 |
if [ `expr "$readlinkPath" : '\([^ ]*\)'` = "no" ] |
| 49 |
then |
| 50 |
echo "No readlink command available, please set $2." |
| 51 |
exit 1 |
| 52 |
else |
| 53 |
readlinkValue=`readlink -f $1` |
| 54 |
fi |
| 55 |
;; |
| 56 |
*) |
| 57 |
readlinkValue=`readlink -f $1` |
| 58 |
;; |
| 59 |
esac |
| 60 |
} |
| 61 |
|
| 62 |
# If GANT_HOME is not set, deduce a path. Assume the executable is in $GANT_HOME/bin. |
| 63 |
|
| 64 |
if [ -z "$GANT_HOME" ] |
| 65 |
then |
| 66 |
if [ -h $0 ] |
| 67 |
then |
| 68 |
doReadLink $0 GANT_HOME |
| 69 |
GANT_HOME=$readlinkValue |
| 70 |
GANT_HOME=`dirname $GANT_HOME` |
| 71 |
else |
| 72 |
GANT_HOME=`dirname $0` |
| 73 |
fi |
| 74 |
GANT_HOME=`dirname $GANT_HOME` |
| 75 |
fi |
| 76 |
|
| 77 |
# If GROOVY_HOME is not set, deduce a path -- this is needed in order to discover the location of the |
| 78 |
# startGroovy script. Assume the executable is in $GROOVY_HOME/bin. |
| 79 |
|
| 80 |
if [ -z "$GROOVY_HOME" ] |
| 81 |
then |
| 82 |
GROOVY_HOME=`which groovy` |
| 83 |
if [ -h $GROOVY_HOME ] |
| 84 |
then |
| 85 |
doReadLink $GROOVY_HOME GROOVY_HOME |
| 86 |
GROOVY_HOME=$readlinkValue |
| 87 |
fi |
| 88 |
GROOVY_HOME=`dirname "$GROOVY_HOME"` |
| 89 |
GROOVY_HOME=`dirname "$GROOVY_HOME"` |
| 90 |
fi |
| 91 |
|
| 92 |
# If ANT_HOME is not set, deduce a path -- this is needed in order to discover the location of the jars |
| 93 |
# associated with the Ant installation. Assume the executable is in $ANT_HOME/bin. |
| 94 |
|
| 95 |
if [ -z "$ANT_HOME" ] |
| 96 |
then |
| 97 |
ANT_HOME=`which ant` |
| 98 |
if [ -h $ANT_HOME ] |
| 99 |
then |
| 100 |
doReadLink $ANT_HOME ANT_HOME |
| 101 |
ANT_HOME=$readlinkValue |
| 102 |
fi |
| 103 |
ANT_HOME=`dirname "$ANT_HOME"` |
| 104 |
ANT_HOME=`dirname "$ANT_HOME"` |
| 105 |
fi |
| 106 |
|
| 107 |
GROOVY_APP_NAME=Gant |
| 108 |
GROOVY_CONF="$GANT_HOME/conf/gant-starter.conf" |
| 109 |
|
| 110 |
. "$GROOVY_HOME/bin/startGroovy" |
| 111 |
|
| 112 |
if $cygwin |
| 113 |
then |
| 114 |
GANT_HOME=`cygpath --mixed "$GANT_HOME"` |
| 115 |
ANT_HOME=`cygpath --mixed "$ANT_HOME"` |
| 116 |
fi |
| 117 |
JAVA_OPTS="$JAVA_OPTS -Dgant.home=$GANT_HOME -Dant.home=$ANT_HOME" |
| 118 |
|
| 119 |
startGroovy gant.Gant "$@" |