From 26bbe3d5c2e51736a04c21e2e9d8220588614d09 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Wed, 9 May 2012 10:27:08 +0000 Subject: SONARPLUGINS-1582 Improve the script --- src/main/assembly/bin/sonar-runner.bat | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src') 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 ==== -- cgit v1.2.3