@@ -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; |
@@ -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"); | |||
} | |||
@@ -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; |
@@ -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; |
@@ -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; |
@@ -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 "$@" | |||
@@ -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% |
@@ -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 | |||
@@ -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" |
@@ -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 |
@@ -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 | |||
@@ -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 |
@@ -12,7 +12,6 @@ | |||
<directory>src/main/assembly/bin</directory> | |||
<outputDirectory>bin</outputDirectory> | |||
<includes> | |||
<include>sonar-runner.bat</include> | |||
<include>sonar-scanner.bat</include> | |||
<include>sonar-scanner-debug.bat</include> | |||
</includes> | |||
@@ -23,7 +22,6 @@ | |||
<directory>src/main/assembly/bin</directory> | |||
<outputDirectory>bin</outputDirectory> | |||
<includes> | |||
<include>sonar-runner</include> | |||
<include>sonar-scanner</include> | |||
<include>sonar-scanner-debug</include> | |||
</includes> |