From b0583c0fbddafdd013bd9289d0385beb1c299a17 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Fri, 28 Jul 2017 12:36:45 +0200 Subject: [PATCH] SQSCANNER-43 Remove deprecated sonar-runner bat/sh scripts --- .../scanner}/it/DistributionTest.java | 2 +- .../scanner}/it/JavaTest.java | 25 +----- .../scanner}/it/MultimoduleTest.java | 2 +- .../scanner}/it/ScannerTestCase.java | 2 +- .../scanner}/it/SonarScannerTestSuite.java | 2 +- src/main/assembly/bin/sonar-runner | 77 ---------------- src/main/assembly/bin/sonar-runner.bat | 89 ------------------- src/main/assembly/bin/sonar-scanner | 2 +- src/main/assembly/bin/sonar-scanner-debug | 2 +- src/main/assembly/bin/sonar-scanner-debug.bat | 3 +- src/main/assembly/bin/sonar-scanner.bat | 2 +- .../assembly/conf/sonar-scanner.properties | 2 +- src/main/assembly/noarch.xml | 2 - 13 files changed, 11 insertions(+), 201 deletions(-) rename it/src/test/java/com/{sonar/runner => sonarsource/scanner}/it/DistributionTest.java (98%) rename it/src/test/java/com/{sonar/runner => sonarsource/scanner}/it/JavaTest.java (91%) rename it/src/test/java/com/{sonar/runner => sonarsource/scanner}/it/MultimoduleTest.java (99%) rename it/src/test/java/com/{sonar/runner => sonarsource/scanner}/it/ScannerTestCase.java (99%) rename it/src/test/java/com/{sonar/runner => sonarsource/scanner}/it/SonarScannerTestSuite.java (97%) delete mode 100755 src/main/assembly/bin/sonar-runner delete mode 100644 src/main/assembly/bin/sonar-runner.bat diff --git a/it/src/test/java/com/sonar/runner/it/DistributionTest.java b/it/src/test/java/com/sonarsource/scanner/it/DistributionTest.java similarity index 98% rename from it/src/test/java/com/sonar/runner/it/DistributionTest.java rename to it/src/test/java/com/sonarsource/scanner/it/DistributionTest.java index 6bd2651..310ffba 100644 --- a/it/src/test/java/com/sonar/runner/it/DistributionTest.java +++ b/it/src/test/java/com/sonarsource/scanner/it/DistributionTest.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package com.sonar.runner.it; +package com.sonarsource.scanner.it; import com.sonar.orchestrator.build.BuildFailureException; import com.sonar.orchestrator.build.SonarScanner; diff --git a/it/src/test/java/com/sonar/runner/it/JavaTest.java b/it/src/test/java/com/sonarsource/scanner/it/JavaTest.java similarity index 91% rename from it/src/test/java/com/sonar/runner/it/JavaTest.java rename to it/src/test/java/com/sonarsource/scanner/it/JavaTest.java index 7337757..1f53a88 100644 --- a/it/src/test/java/com/sonar/runner/it/JavaTest.java +++ b/it/src/test/java/com/sonarsource/scanner/it/JavaTest.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package com.sonar.runner.it; +package com.sonarsource.scanner.it; import com.sonar.orchestrator.build.BuildResult; import com.sonar.orchestrator.build.SonarScanner; @@ -27,7 +27,6 @@ import java.io.IOException; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import org.apache.commons.lang.SystemUtils; import org.junit.After; import org.junit.Rule; import org.junit.Test; @@ -285,32 +284,12 @@ public class JavaTest extends ScannerTestCase { } @Test - public void use_old_script_and_old_env_variable() { - SonarScanner build = newScanner(new File("projects/java-sample")) - .setUseOldSonarRunnerScript(true) - .setEnvironmentVariable("SONAR_RUNNER_OPTS", "-Xmx2m"); - BuildResult executeBuild = orchestrator.executeBuildQuietly(build); - assertThat(executeBuild.getStatus()).isNotEqualTo(0); - String logs = executeBuild.getLogs(); - if (SystemUtils.IS_OS_WINDOWS) { - assertThat(logs).contains("WARN: sonar-runner.bat script is deprecated. Please use sonar-scanner.bat instead."); - assertThat(logs).contains("WARN: SONAR_RUNNER_OPTS is deprecated. Please use SONAR_SCANNER_OPTS instead."); - } else { - assertThat(logs).contains("WARN: sonar-runner script is deprecated. Please use sonar-scanner instead."); - assertThat(logs).contains("WARN: $SONAR_RUNNER_OPTS is deprecated. Please use $SONAR_SCANNER_OPTS instead."); - } - assertThat(logs).contains("java.lang.OutOfMemoryError"); - } - - @Test - public void use_new_script_and_new_env_variable() { + public void verify_env_variable() { SonarScanner build = newScanner(new File("projects/java-sample")) .setEnvironmentVariable("SONAR_SCANNER_OPTS", "-Xmx2m"); BuildResult executeBuild = orchestrator.executeBuildQuietly(build); assertThat(executeBuild.getStatus()).isNotEqualTo(0); String logs = executeBuild.getLogs(); - assertThat(logs).doesNotContain("sonar-runner"); - assertThat(logs).doesNotContain("SONAR_RUNNER_OPTS"); assertThat(logs).contains("java.lang.OutOfMemoryError"); } diff --git a/it/src/test/java/com/sonar/runner/it/MultimoduleTest.java b/it/src/test/java/com/sonarsource/scanner/it/MultimoduleTest.java similarity index 99% rename from it/src/test/java/com/sonar/runner/it/MultimoduleTest.java rename to it/src/test/java/com/sonarsource/scanner/it/MultimoduleTest.java index 9486dec..52931ee 100644 --- a/it/src/test/java/com/sonar/runner/it/MultimoduleTest.java +++ b/it/src/test/java/com/sonarsource/scanner/it/MultimoduleTest.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package com.sonar.runner.it; +package com.sonarsource.scanner.it; import com.sonar.orchestrator.build.BuildResult; import com.sonar.orchestrator.build.SonarScanner; diff --git a/it/src/test/java/com/sonar/runner/it/ScannerTestCase.java b/it/src/test/java/com/sonarsource/scanner/it/ScannerTestCase.java similarity index 99% rename from it/src/test/java/com/sonar/runner/it/ScannerTestCase.java rename to it/src/test/java/com/sonarsource/scanner/it/ScannerTestCase.java index 4f32725..be19ea9 100644 --- a/it/src/test/java/com/sonar/runner/it/ScannerTestCase.java +++ b/it/src/test/java/com/sonarsource/scanner/it/ScannerTestCase.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package com.sonar.runner.it; +package com.sonarsource.scanner.it; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; diff --git a/it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java b/it/src/test/java/com/sonarsource/scanner/it/SonarScannerTestSuite.java similarity index 97% rename from it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java rename to it/src/test/java/com/sonarsource/scanner/it/SonarScannerTestSuite.java index f36120b..6b157b2 100644 --- a/it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java +++ b/it/src/test/java/com/sonarsource/scanner/it/SonarScannerTestSuite.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package com.sonar.runner.it; +package com.sonarsource.scanner.it; import com.sonar.orchestrator.Orchestrator; import org.junit.ClassRule; diff --git a/src/main/assembly/bin/sonar-runner b/src/main/assembly/bin/sonar-runner deleted file mode 100755 index a116ea4..0000000 --- a/src/main/assembly/bin/sonar-runner +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh -# -# SonarQube Runner Startup Script for Unix -# -# Optional ENV vars: -# SONAR_RUNNER_OPTS - Parameters passed to the Java VM when running Sonar -# JAVA_HOME - Location of Java's installation - -real_path () { - target=$1 - - ( - while true; do - cd "$(dirname "$target")" - target=$(basename "$target") - link=$(readlink "$target") - test "$link" || break - target=$link - done - - echo "$(pwd -P)/$target" - ) -} - -echo WARN: 'sonar-runner' script is deprecated. Please use 'sonar-scanner' instead. - -script_path="$0" - -if [ -h "$script_path" ] ; then - # resolve recursively symlinks - script_path=$(real_path "$script_path") -fi - -sonar_runner_home=$(dirname "$script_path")/.. - -# make it fully qualified -sonar_runner_home=$(cd "$sonar_runner_home" && pwd) - -jar_file=$sonar_runner_home/lib/sonar-scanner-cli-${project.version}.jar - -# check that sonar_runner_home has been correctly set -if [ ! -f "$jar_file" ] ; then - echo "File does not exist: $jar_file" - echo "'$sonar_runner_home' does not point to a valid installation directory: $sonar_runner_home" - exit 1 -fi - -if [ -n "$JAVA_HOME" ] -then - java_cmd="$JAVA_HOME/bin/java" -else - java_cmd="$(which java)" -fi - -if [ -n "$SONAR_RUNNER_OPTS" ] ; -then - echo WARN: '$SONAR_RUNNER_OPTS' is deprecated. Please use '$SONAR_SCANNER_OPTS' instead. - if [ -z "$SONAR_SCANNER_OPTS" ] ; then - SONAR_SCANNER_OPTS=$SONAR_RUNNER_OPTS - fi -fi - -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" - -exec "$java_cmd" \ - -Djava.awt.headless=true \ - $SONAR_SCANNER_OPTS \ - -classpath "$jar_file" \ - -Dscanner.home="$sonar_runner_home" \ - -Dproject.home="$project_home" \ - org.sonarsource.scanner.cli.Main "$@" - diff --git a/src/main/assembly/bin/sonar-runner.bat b/src/main/assembly/bin/sonar-runner.bat deleted file mode 100644 index 0c5fdb2..0000000 --- a/src/main/assembly/bin/sonar-runner.bat +++ /dev/null @@ -1,89 +0,0 @@ -@REM SonarQube Runner Startup Script for Windows -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars: -@REM SONAR_RUNNER_OPTS - parameters passed to the Java VM when running Sonar - -@echo off - -set ERROR_CODE=0 - -@REM set local scope for the variables with windows NT shell -@setlocal - -echo WARN: sonar-runner.bat script is deprecated. Please use sonar-scanner.bat instead. - -@REM ==== START VALIDATION ==== -@REM *** JAVA EXEC VALIDATION *** -if not "%JAVA_HOME%" == "" goto foundJavaHome - -for %%i in (java.exe) do set JAVA_EXEC=%%~$PATH:i - -if not "%JAVA_EXEC%" == "" ( - set JAVA_EXEC="%JAVA_EXEC%" - goto OkJava -) - -if not "%JAVA_EXEC%" == "" goto OkJava - -echo. -echo ERROR: JAVA_HOME not found in your environment, and no Java -echo executable present in the PATH. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation, or add "java.exe" to the PATH -echo. -goto error - -:foundJavaHome -if EXIST "%JAVA_HOME%\bin\java.exe" goto foundJavaExeFromJavaHome - -echo. -echo ERROR: JAVA_HOME exists but does not point to a valid Java home -echo folder. No "\bin\java.exe" file can be found there. -echo. -goto error - -:foundJavaExeFromJavaHome -set JAVA_EXEC="%JAVA_HOME%\bin\java.exe" - -:OkJava -set SONAR_RUNNER_HOME=%~dp0.. -goto sonarRunnerOpts - -@REM ==== HANDLE DEPRECATED SONAR_RUNNER_OPTS ==== -:sonarRunnerOpts -if "%SONAR_RUNNER_OPTS%" == "" ( - goto run -) else ( - echo WARN: SONAR_RUNNER_OPTS is deprecated. Please use SONAR_SCANNER_OPTS instead. - if "%SONAR_SCANNER_OPTS%" == "" (set SONAR_SCANNER_OPTS=%SONAR_RUNNER_OPTS%) -) - -@REM ==== START RUN ==== -:run - -set PROJECT_HOME=%CD% - -%JAVA_EXEC% -Djava.awt.headless=true %SONAR_SCANNER_OPTS% -cp "%SONAR_RUNNER_HOME%\lib\sonar-scanner-cli-${project.version}.jar" "-Dscanner.home=%SONAR_RUNNER_HOME%" "-Dproject.home=%PROJECT_HOME%" org.sonarsource.scanner.cli.Main %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -@REM ==== END EXECUTION ==== - -:end -@REM set local scope for the variables with windows NT shell -@endlocal & set ERROR_CODE=%ERROR_CODE% - -@REM see http://code-bear.com/bearlog/2007/06/01/getting-the-exit-code-from-a-batch-file-that-is-run-from-a-python-program/ -goto exit - -:returncode -exit /B %1 - -:exit -call :returncode %ERROR_CODE% diff --git a/src/main/assembly/bin/sonar-scanner b/src/main/assembly/bin/sonar-scanner index 985de89..d6ffd57 100755 --- a/src/main/assembly/bin/sonar-scanner +++ b/src/main/assembly/bin/sonar-scanner @@ -3,7 +3,7 @@ # SonarQube Scanner Startup Script for Unix # # Optional ENV vars: -# SONAR_SCANNER_OPTS - Parameters passed to the Java VM when running SonarQube Scanner +# SONAR_SCANNER_OPTS - Parameters passed to the Java VM when running the SonarQube Scanner # SONAR_SCANNER_DEBUG_OPTS - Extra parameters passed to the Java VM for debugging # JAVA_HOME - Location of Java's installation diff --git a/src/main/assembly/bin/sonar-scanner-debug b/src/main/assembly/bin/sonar-scanner-debug index 257835e..d43b036 100755 --- a/src/main/assembly/bin/sonar-scanner-debug +++ b/src/main/assembly/bin/sonar-scanner-debug @@ -3,7 +3,7 @@ # SonarQube Scanner Startup Script for Unix # # Optional ENV vars: -# SONAR_SCANNER_OPTS - parameters passed to the Java VM when running SonarQube Scanner +# SONAR_SCANNER_OPTS - parameters passed to the Java VM when running the SonarQube Scanner # JAVA_HOME - Location of Java's installation SONAR_SCANNER_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000" diff --git a/src/main/assembly/bin/sonar-scanner-debug.bat b/src/main/assembly/bin/sonar-scanner-debug.bat index e0942c8..1ebc42c 100644 --- a/src/main/assembly/bin/sonar-scanner-debug.bat +++ b/src/main/assembly/bin/sonar-scanner-debug.bat @@ -4,8 +4,7 @@ @REM JAVA_HOME - location of a JDK home dir @REM @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 the SonarQube Scanner @setlocal @set SONAR_SCANNER_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 diff --git a/src/main/assembly/bin/sonar-scanner.bat b/src/main/assembly/bin/sonar-scanner.bat index c75e28e..970af4b 100644 --- a/src/main/assembly/bin/sonar-scanner.bat +++ b/src/main/assembly/bin/sonar-scanner.bat @@ -4,7 +4,7 @@ @REM JAVA_HOME - location of a JDK home dir @REM @REM Optional ENV vars: -@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 the SonarQube Scanner @echo off diff --git a/src/main/assembly/conf/sonar-scanner.properties b/src/main/assembly/conf/sonar-scanner.properties index 69a52a2..b30e841 100644 --- a/src/main/assembly/conf/sonar-scanner.properties +++ b/src/main/assembly/conf/sonar-scanner.properties @@ -1,4 +1,4 @@ -#Configure here general information about the environment, such as SonarQube DB details for example +#Configure here general information about the environment, such as SonarQube server connection details for example #No information about specific project should appear here #----- Default SonarQube server diff --git a/src/main/assembly/noarch.xml b/src/main/assembly/noarch.xml index cce6955..e226a7a 100644 --- a/src/main/assembly/noarch.xml +++ b/src/main/assembly/noarch.xml @@ -12,7 +12,6 @@ src/main/assembly/bin bin - sonar-runner.bat sonar-scanner.bat sonar-scanner-debug.bat @@ -23,7 +22,6 @@ src/main/assembly/bin bin - sonar-runner sonar-scanner sonar-scanner-debug -- 2.39.5