summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2012-05-09 10:27:08 +0000
committerFabrice Bellingard <bellingard@gmail.com>2012-05-09 10:27:08 +0000
commit26bbe3d5c2e51736a04c21e2e9d8220588614d09 (patch)
tree9b1f882fbedee485a3efdcbdc87427ad19a844fb /src
parent49292e1daed848a14191c14cd1525b3650157fc2 (diff)
downloadsonar-scanner-cli-26bbe3d5c2e51736a04c21e2e9d8220588614d09.tar.gz
sonar-scanner-cli-26bbe3d5c2e51736a04c21e2e9d8220588614d09.zip
SONARPLUGINS-1582 Improve the script
Diffstat (limited to 'src')
-rw-r--r--src/main/assembly/bin/sonar-runner.bat31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/main/assembly/bin/sonar-runner.bat b/src/main/assembly/bin/sonar-runner.bat
index 87007c0..6f24d89 100644
--- a/src/main/assembly/bin/sonar-runner.bat
+++ b/src/main/assembly/bin/sonar-runner.bat
@@ -11,32 +11,53 @@
@REM ==== START VALIDATION ====
-if not "%JAVA_HOME%" == "" goto OkJavaHome
+@REM => JAVA EXEC
+if not "%JAVA_HOME%" == "" goto foundJavaHome
+
+for %%i in (java.exe) do set JAVA_EXEC=%%~$PATH:i
+
+if not "%JAVA_EXEC%" == "" goto OkJava
echo.
-echo ERROR: JAVA_HOME not found in your environment.
+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
+echo location of your Java installation, or add "java.exe" to the PATH
+echo.
+goto end
+
+: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 end
-:OkJavaHome
+:foundJavaExeFromJavaHome
+set JAVA_EXEC="%JAVA_HOME%\bin\java.exe"
+
+:OkJava
if NOT "%SONAR_RUNNER_HOME%"=="" goto cleanSonarRunnerHome
set SONAR_RUNNER_HOME=%~dp0..
goto run
+@REM => SONAR_RUNNER_HOME
: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 ==== START RUN ====
:run
echo %SONAR_RUNNER_HOME%
set PROJECT_HOME=%CD%
-"%JAVA_HOME%\bin\java.exe" %SONAR_RUNNER_OPTS% -classpath "%SONAR_RUNNER_HOME%\lib\sonar-runner.jar";"%SONAR_RUNNER_HOME%\lib\sonar-batch-bootstrapper.jar" "-Drunner.home=%SONAR_RUNNER_HOME%" "-Dproject.home=%PROJECT_HOME%" org.sonar.runner.Main %*
+%JAVA_EXEC% %SONAR_RUNNER_OPTS% -classpath "%SONAR_RUNNER_HOME%\lib\sonar-runner.jar";"%SONAR_RUNNER_HOME%\lib\sonar-batch-bootstrapper.jar" "-Drunner.home=%SONAR_RUNNER_HOME%" "-Dproject.home=%PROJECT_HOME%" org.sonar.runner.Main %*
+
@REM ==== END EXECUTION ====