You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sonar-runner.bat 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. @REM SonarQube Runner Startup Script for Windows
  2. @REM
  3. @REM Required ENV vars:
  4. @REM JAVA_HOME - location of a JDK home dir
  5. @REM
  6. @REM Optional ENV vars:
  7. @REM SONAR_RUNNER_OPTS - parameters passed to the Java VM when running Sonar
  8. @echo off
  9. set ERROR_CODE=0
  10. @REM set local scope for the variables with windows NT shell
  11. @setlocal
  12. echo WARN: sonar-runner.bat script is deprecated. Please use sonar-scanner.bat instead.
  13. @REM ==== START VALIDATION ====
  14. @REM *** JAVA EXEC VALIDATION ***
  15. if not "%JAVA_HOME%" == "" goto foundJavaHome
  16. for %%i in (java.exe) do set JAVA_EXEC=%%~$PATH:i
  17. if not "%JAVA_EXEC%" == "" (
  18. set JAVA_EXEC="%JAVA_EXEC%"
  19. goto OkJava
  20. )
  21. if not "%JAVA_EXEC%" == "" goto OkJava
  22. echo.
  23. echo ERROR: JAVA_HOME not found in your environment, and no Java
  24. echo executable present in the PATH.
  25. echo Please set the JAVA_HOME variable in your environment to match the
  26. echo location of your Java installation, or add "java.exe" to the PATH
  27. echo.
  28. goto error
  29. :foundJavaHome
  30. if EXIST "%JAVA_HOME%\bin\java.exe" goto foundJavaExeFromJavaHome
  31. echo.
  32. echo ERROR: JAVA_HOME exists but does not point to a valid Java home
  33. echo folder. No "\bin\java.exe" file can be found there.
  34. echo.
  35. goto error
  36. :foundJavaExeFromJavaHome
  37. set JAVA_EXEC="%JAVA_HOME%\bin\java.exe"
  38. :OkJava
  39. set SONAR_RUNNER_HOME=%~dp0..
  40. goto sonarRunnerOpts
  41. @REM ==== HANDLE DEPRECATED SONAR_RUNNER_OPTS ====
  42. :sonarRunnerOpts
  43. if "%SONAR_RUNNER_OPTS%" == "" (
  44. goto run
  45. ) else (
  46. echo WARN: SONAR_RUNNER_OPTS is deprecated. Please use SONAR_SCANNER_OPTS instead.
  47. if "%SONAR_SCANNER_OPTS%" == "" (set SONAR_SCANNER_OPTS=%SONAR_RUNNER_OPTS%)
  48. )
  49. @REM ==== START RUN ====
  50. :run
  51. echo %SONAR_RUNNER_HOME%
  52. set PROJECT_HOME=%CD%
  53. %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 %*
  54. if ERRORLEVEL 1 goto error
  55. goto end
  56. :error
  57. set ERROR_CODE=1
  58. @REM ==== END EXECUTION ====
  59. :end
  60. @REM set local scope for the variables with windows NT shell
  61. @endlocal & set ERROR_CODE=%ERROR_CODE%
  62. @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/
  63. goto exit
  64. :returncode
  65. exit /B %1
  66. :exit
  67. call :returncode %ERROR_CODE%