|
| 1 | +#!/bin/sh |
| 2 | +# |
| 3 | +# Sonar Runner Startup Script for Unix |
| 4 | +# |
| 5 | +# Optional ENV vars: |
| 6 | +# SONAR_RUNNER_HOME - location of runner's installed home dir |
| 7 | +# SONAR_RUNNER_OPTS - parameters passed to the Java VM when running Sonar |
| 8 | + |
| 9 | +# The following notice only apply to real_path function copied from |
| 10 | +# https://sites.google.com/site/jdisnard/realpath |
| 11 | +# Copyright 2010 Jon Disnard. All rights reserved. |
| 12 | +# |
| 13 | +# Redistribution and use in source and binary forms, with or without modification, are |
| 14 | +# permitted provided that the following conditions are met: |
| 15 | +# |
| 16 | +# 1. Redistributions of source code must retain the above copyright notice, this list of |
| 17 | +# conditions and the following disclaimer. |
| 18 | +# |
| 19 | +# 2. Redistributions in binary form must reproduce the above copyright notice, this list |
| 20 | +# of conditions and the following disclaimer in the documentation and/or other materials |
| 21 | +# provided with the distribution. |
| 22 | +# |
| 23 | +# THIS SOFTWARE IS PROVIDED BY Jon Disnard ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 24 | +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 25 | +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR |
| 26 | +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 27 | +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 28 | +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 29 | +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 30 | +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 31 | +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | +# |
| 33 | +# The views and conclusions contained in the software and documentation are those of the |
| 34 | +# authors and should not be interpreted as representing official policies, either expressed |
| 35 | +# or implied, of Jon Disnard. |
| 36 | +real_path () { |
| 37 | + OIFS=$IFS |
| 38 | + IFS='/' |
| 39 | + for I in $1 |
| 40 | + do |
| 41 | + # Resolve relative path punctuation. |
| 42 | + if [ "$I" = "." ] || [ -z "$I" ] |
| 43 | + then continue |
| 44 | + elif [ "$I" = ".." ] |
| 45 | + then FOO="${FOO%%/${FOO##*/}}" |
| 46 | + continue |
| 47 | + else FOO="${FOO}/${I}" |
| 48 | + fi |
| 49 | + |
| 50 | + # Dereference symbolic links. |
| 51 | + if [ -h "$FOO" ] && [ -x "/bin/ls" ] |
| 52 | + then IFS=$OIFS |
| 53 | + set `/bin/ls -l "$FOO"` |
| 54 | + while shift ; |
| 55 | + do |
| 56 | + if [ "$1" = "->" ] |
| 57 | + then FOO=$2 |
| 58 | + shift $# |
| 59 | + break |
| 60 | + fi |
| 61 | + done |
| 62 | + fi |
| 63 | + done |
| 64 | + IFS=$OIFS |
| 65 | + echo "$FOO" |
| 66 | +} |
| 67 | + |
| 68 | +if [ -z "$SONAR_RUNNER_HOME" ] ; then |
| 69 | + PRG="$0" |
| 70 | + |
| 71 | + # resolve symlinks |
| 72 | + PRG=`real_path "$PRG"` |
| 73 | + |
| 74 | + SONAR_RUNNER_HOME=`dirname "$PRG"`/.. |
| 75 | + |
| 76 | + # make it fully qualified |
| 77 | + SONAR_RUNNER_HOME=`cd "$SONAR_RUNNER_HOME" && pwd` |
| 78 | +fi |
| 79 | + |
| 80 | +# check that the SONAR_RUNNER_HOME has been correctly set |
| 81 | +if [ ! -e "$SONAR_RUNNER_HOME/lib/sonar-runner-impl-2.1.jar" ] ; then |
| 82 | + echo '$SONAR_RUNNER_HOME' does not point to a valid installation directory: $SONAR_RUNNER_HOME |
| 83 | + exit 1 |
| 84 | +fi |
| 85 | + |
| 86 | +JAVA_CMD="`which java`" |
| 87 | +JAVA_CLASSPATH="${SONAR_RUNNER_HOME}"/lib/sonar-runner-impl-2.1.jar |
| 88 | +PROJECT_HOME=`pwd` |
| 89 | + |
| 90 | +#echo "Info: Using sonar-runner at $SONAR_RUNNER_HOME" |
| 91 | +#echo "Info: Using java at $JAVA_CMD" |
| 92 | +#echo "Info: Using classpath $JAVA_CLASSPATH" |
| 93 | +#echo "Info: Using project $PROJECT_HOME" |
| 94 | + |
| 95 | +exec "$JAVA_CMD" \ |
| 96 | + $SONAR_RUNNER_OPTS \ |
| 97 | + -classpath $JAVA_CLASSPATH \ |
| 98 | + "-Drunner.home=${SONAR_RUNNER_HOME}" \ |
| 99 | + "-Dproject.home=${PROJECT_HOME}" \ |
| 100 | + org.sonar.runner.Main "$@" |
0 commit comments