Przeglądaj źródła

SQSCANNER-34 Don't use user-defined SONAR_SCANNER_HOME

tags/2.9.0.670
Duarte Meneses 7 lat temu
rodzic
commit
3be4a20b49

+ 28
- 30
src/main/assembly/bin/sonar-runner Wyświetl plik

# SonarQube Runner Startup Script for Unix # SonarQube Runner Startup Script for Unix
# #
# Optional ENV vars: # Optional ENV vars:
# SONAR_RUNNER_HOME - location of runner's installed home dir
# SONAR_RUNNER_OPTS - parameters passed to the Java VM when running Sonar
# SONAR_RUNNER_OPTS - Parameters passed to the Java VM when running Sonar
# JAVA_HOME - Location of Java's installation


# The following notice only apply to real_path function copied from # The following notice only apply to real_path function copied from
# https://sites.google.com/site/jdisnard/realpath # https://sites.google.com/site/jdisnard/realpath


echo WARN: 'sonar-runner' script is deprecated. Please use 'sonar-scanner' instead. echo WARN: 'sonar-runner' script is deprecated. Please use 'sonar-scanner' instead.


if [ -z "$SONAR_RUNNER_HOME" ] ; then
PRG="$0"
PRG="$0"


if [ -h "$PRG" ] ; then
# resolve recursively symlinks
if [ -h "$PRG" ] ; then
# resolve recursively symlinks
R_PRG=`real_path "$PRG"`
until [ "$R_PRG" = "$PRG" ]; do
PRG="$R_PRG"
R_PRG=`real_path "$PRG"` R_PRG=`real_path "$PRG"`
until [ "$R_PRG" = "$PRG" ]; do
PRG="$R_PRG"
R_PRG=`real_path "$PRG"`
done
fi
done
fi


SONAR_RUNNER_HOME=`dirname "$PRG"`/..
sonar_runner_home=`dirname "$PRG"`/..


# make it fully qualified
SONAR_RUNNER_HOME=`cd "$SONAR_RUNNER_HOME" && pwd`
fi
# make it fully qualified
sonar_runner_home=`cd "$sonar_runner_home" && pwd`


# check that the SONAR_RUNNER_HOME has been correctly set
if [ ! -f "$SONAR_RUNNER_HOME/lib/sonar-scanner-cli-${project.version}.jar" ] ; then
echo '$SONAR_RUNNER_HOME' does not point to a valid installation directory: $SONAR_RUNNER_HOME
# check that the sonar_runner_home has been correctly set
if [ ! -f "$sonar_runner_home/lib/sonar-scanner-cli-${project.version}.jar" ] ; then
echo '$sonar_runner_home' does not point to a valid installation directory: $sonar_runner_home
exit 1 exit 1
fi fi


if [ -n "$JAVA_HOME" ] if [ -n "$JAVA_HOME" ]
then then
JAVA_CMD="$JAVA_HOME/bin/java"
java_cmd="$JAVA_HOME/bin/java"
else else
JAVA_CMD="`which java`"
java_cmd="`which java`"
fi fi


if [ -n "$SONAR_RUNNER_OPTS" ] ; if [ -n "$SONAR_RUNNER_OPTS" ] ;
fi fi
fi fi


JAR_FILE="${SONAR_RUNNER_HOME}"/lib/sonar-scanner-cli-${project.version}.jar
PROJECT_HOME=`pwd`
jar_file="${sonar_runner_home}"/lib/sonar-scanner-cli-${project.version}.jar
project_home=`pwd`


#echo "Info: Using sonar-runner at $SONAR_RUNNER_HOME"
#echo "Info: Using java at $JAVA_CMD"
#echo "Info: Using classpath $JAR_FILE"
#echo "Info: Using project $PROJECT_HOME"
#echo "Info: Using sonar-runner at $sonar_runner_home"
#echo "Info: Using java at $java_cmd"
#echo "Info: Using classpath $jar_file"
#echo "Info: Using project $project_home"


exec "$JAVA_CMD" \
exec "$java_cmd" \
-Djava.awt.headless=true \ -Djava.awt.headless=true \
$SONAR_SCANNER_OPTS \ $SONAR_SCANNER_OPTS \
-classpath $JAR_FILE \
"-Dscanner.home=\${SONAR_RUNNER_HOME}" \
"-Dproject.home=\${PROJECT_HOME}" \
-classpath $jar_file \
"-Dscanner.home=\${sonar_runner_home}" \
"-Dproject.home=\${project_home}" \
org.sonarsource.scanner.cli.Main "$@" org.sonarsource.scanner.cli.Main "$@"



+ 0
- 16
src/main/assembly/bin/sonar-runner.bat Wyświetl plik

@REM JAVA_HOME - location of a JDK home dir @REM JAVA_HOME - location of a JDK home dir
@REM @REM
@REM Optional ENV vars: @REM Optional ENV vars:
@REM SONAR_RUNNER_HOME - location of runner's installed home dir
@REM SONAR_RUNNER_OPTS - parameters passed to the Java VM when running Sonar @REM SONAR_RUNNER_OPTS - parameters passed to the Java VM when running Sonar


@echo off @echo off
:foundJavaExeFromJavaHome :foundJavaExeFromJavaHome
set JAVA_EXEC="%JAVA_HOME%\bin\java.exe" set JAVA_EXEC="%JAVA_HOME%\bin\java.exe"


@REM *** SONAR RUNNER HOME VALIDATION ***
:OkJava :OkJava
if NOT "%SONAR_RUNNER_HOME%"=="" goto cleanSonarRunnerHome
set SONAR_RUNNER_HOME=%~dp0.. set SONAR_RUNNER_HOME=%~dp0..
goto sonarRunnerOpts goto sonarRunnerOpts


:cleanSonarRunnerHome
@REM If the property has a trailing backslash, remove it
if "%SONAR_RUNNER_HOME:~-1%"=="\" set SONAR_RUNNER_HOME=%SONAR_RUNNER_HOME:~0,-1%

@REM Check if the provided SONAR_RUNNER_HOME is a valid install dir
IF EXIST "%SONAR_RUNNER_HOME%\lib\sonar-scanner-cli-${project.version}.jar" goto sonarRunnerOpts

echo.
echo ERROR: SONAR_RUNNER_HOME exists but does not point to a valid install
echo directory: %SONAR_RUNNER_HOME%
echo.
goto error

@REM ==== HANDLE DEPRECATED SONAR_RUNNER_OPTS ==== @REM ==== HANDLE DEPRECATED SONAR_RUNNER_OPTS ====
:sonarRunnerOpts :sonarRunnerOpts
if "%SONAR_RUNNER_OPTS%" == "" ( if "%SONAR_RUNNER_OPTS%" == "" (

+ 28
- 30
src/main/assembly/bin/sonar-scanner Wyświetl plik

# SonarQube Scanner Startup Script for Unix # SonarQube Scanner Startup Script for Unix
# #
# Optional ENV vars: # Optional ENV vars:
# SONAR_SCANNER_HOME - location of runner's installed home dir
# SONAR_SCANNER_OPTS - parameters passed to the Java VM when running SonarQube Scanner
# SONAR_SCANNER_OPTS - Parameters passed to the Java VM when running SonarQube Scanner
# SONAR_SCANNER_DEBUG_OPTS - Extra parameters passed to the Java VM for debugging # SONAR_SCANNER_DEBUG_OPTS - Extra parameters passed to the Java VM for debugging
# JAVA_HOME - Location of Java's installation


# The following notice only apply to real_path function copied from # The following notice only apply to real_path function copied from
# https://sites.google.com/site/jdisnard/realpath # https://sites.google.com/site/jdisnard/realpath
echo "$FOO" echo "$FOO"
} }


if [ -z "$SONAR_SCANNER_HOME" ] ; then
PRG="$0"
PRG="$0"


if [ -h "$PRG" ] ; then
# resolve recursively symlinks
if [ -h "$PRG" ] ; then
# resolve recursively symlinks
R_PRG=`real_path "$PRG"`
until [ "$R_PRG" = "$PRG" ]; do
PRG="$R_PRG"
R_PRG=`real_path "$PRG"` R_PRG=`real_path "$PRG"`
until [ "$R_PRG" = "$PRG" ]; do
PRG="$R_PRG"
R_PRG=`real_path "$PRG"`
done
fi
done
fi


SONAR_SCANNER_HOME=`dirname "$PRG"`/..
sonar_scanner_home=`dirname "$PRG"`/..


# make it fully qualified
SONAR_SCANNER_HOME=`cd "$SONAR_SCANNER_HOME" && pwd -P`
fi
# make it fully qualified
sonar_scanner_home=`cd "$sonar_scanner_home" && pwd -P`


# check that the SONAR_SCANNER_HOME has been correctly set
if [ ! -f "$SONAR_SCANNER_HOME/lib/sonar-scanner-cli-${project.version}.jar" ] ; then
echo '$SONAR_SCANNER_HOME' does not point to a valid installation directory: $SONAR_SCANNER_HOME
# check that sonar_scanner_home has been correctly set
if [ ! -f "$sonar_scanner_home/lib/sonar-scanner-cli-${project.version}.jar" ] ; then
echo '$sonar_scanner_home' does not point to a valid installation directory: $sonar_scanner_home
exit 1 exit 1
fi fi


if [ -n "$JAVA_HOME" ] if [ -n "$JAVA_HOME" ]
then then
JAVA_CMD="$JAVA_HOME/bin/java"
java_cmd="$JAVA_HOME/bin/java"
else else
JAVA_CMD="`which java`"
java_cmd="`which java`"
fi fi


JAR_FILE="${SONAR_SCANNER_HOME}"/lib/sonar-scanner-cli-${project.version}.jar
PROJECT_HOME=`pwd`
jar_file="${sonar_scanner_home}"/lib/sonar-scanner-cli-${project.version}.jar
project_home=`pwd`


#echo "Info: Using sonar-scanner at $SONAR_SCANNER_HOME"
#echo "Info: Using java at $JAVA_CMD"
#echo "Info: Using classpath $JAR_FILE"
#echo "Info: Using project $PROJECT_HOME"
#echo "Info: Using sonar-scanner at $sonar_scanner_home"
#echo "Info: Using java at $java_cmd"
#echo "Info: Using classpath $jar_file"
#echo "Info: Using project $project_home"


exec "$JAVA_CMD" \
exec "$java_cmd" \
-Djava.awt.headless=true \ -Djava.awt.headless=true \
$SONAR_SCANNER_OPTS \ $SONAR_SCANNER_OPTS \
$SONAR_SCANNER_DEBUG_OPTS \ $SONAR_SCANNER_DEBUG_OPTS \
-classpath $JAR_FILE \
"-Dscanner.home=\${SONAR_SCANNER_HOME}" \
"-Dproject.home=\${PROJECT_HOME}" \
-classpath $jar_file \
"-Dscanner.home=\${sonar_scanner_home}" \
"-Dproject.home=\${project_home}" \
org.sonarsource.scanner.cli.Main "$@" org.sonarsource.scanner.cli.Main "$@"



+ 1
- 1
src/main/assembly/bin/sonar-scanner-debug Wyświetl plik

# SonarQube Scanner Startup Script for Unix # SonarQube Scanner Startup Script for Unix
# #
# Optional ENV vars: # Optional ENV vars:
# SONAR_SCANNER_HOME - location of runner's installed home dir
# SONAR_SCANNER_OPTS - parameters passed to the Java VM when running SonarQube Scanner # SONAR_SCANNER_OPTS - parameters passed to the Java VM when running SonarQube Scanner
# JAVA_HOME - Location of Java's installation


# The following notice only apply to real_path function copied from # The following notice only apply to real_path function copied from
# https://sites.google.com/site/jdisnard/realpath # https://sites.google.com/site/jdisnard/realpath

+ 0
- 17
src/main/assembly/bin/sonar-scanner.bat Wyświetl plik

@REM JAVA_HOME - location of a JDK home dir @REM JAVA_HOME - location of a JDK home dir
@REM @REM
@REM Optional ENV vars: @REM Optional ENV vars:
@REM SONAR_SCANNER_HOME - location of runner's installed home dir
@REM SONAR_SCANNER_OPTS - parameters passed to the Java VM when running Sonar @REM SONAR_SCANNER_OPTS - parameters passed to the Java VM when running Sonar


@echo off @echo off
:foundJavaExeFromJavaHome :foundJavaExeFromJavaHome
set JAVA_EXEC="%JAVA_HOME%\bin\java.exe" set JAVA_EXEC="%JAVA_HOME%\bin\java.exe"


@REM *** SONAR SCANNER HOME VALIDATION ***
:OkJava :OkJava
if NOT "%SONAR_SCANNER_HOME%"=="" goto cleanSQScannerHome
set SONAR_SCANNER_HOME=%~dp0.. set SONAR_SCANNER_HOME=%~dp0..
goto run goto run


:cleanSQScannerHome
@REM If the property has a trailing backslash, remove it
if "%SONAR_SCANNER_HOME:~-1%"=="\" set SONAR_SCANNER_HOME=%SONAR_SCANNER_HOME:~0,-1%

@REM Check if the provided SONAR_SCANNER_HOME is a valid install dir
IF EXIST "%SONAR_SCANNER_HOME%\lib\sonar-scanner-cli-${project.version}.jar" goto run

echo.
echo ERROR: SONAR_SCANNER_HOME exists but does not point to a valid install
echo directory: %SONAR_SCANNER_HOME%
echo.
goto error




@REM ==== START RUN ==== @REM ==== START RUN ====
:run :run

Ładowanie…
Anuluj
Zapisz