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-scanner.bat 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. @REM SonarScanner 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_SCANNER_OPTS - parameters passed to the Java VM when running the SonarScanner
  8. @echo off
  9. set ERROR_CODE=0
  10. @REM set local scope for the variables with windows NT shell
  11. @setlocal
  12. set "scriptdir=%~dp0"
  13. if #%scriptdir:~-1%# == #\# set scriptdir=%scriptdir:~0,-1%
  14. set "SONAR_SCANNER_HOME=%scriptdir%\.."
  15. @REM ==== START VALIDATION ====
  16. @REM *** JAVA EXEC VALIDATION ***
  17. set use_embedded_jre=${use_embedded_jre}
  18. if "%use_embedded_jre%" == "true" (
  19. set "JAVA_HOME=%SONAR_SCANNER_HOME%\jre"
  20. )
  21. if not "%JAVA_HOME%" == "" goto foundJavaHome
  22. for %%i in (java.exe) do set JAVA_EXEC=%%~$PATH:i
  23. if not "%JAVA_EXEC%" == "" (
  24. set JAVA_EXEC="%JAVA_EXEC%"
  25. goto OkJava
  26. )
  27. if not "%JAVA_EXEC%" == "" goto OkJava
  28. echo.
  29. echo ERROR: JAVA_HOME not found in your environment, and no Java
  30. echo executable present in the PATH.
  31. echo Please set the JAVA_HOME variable in your environment to match the
  32. echo location of your Java installation, or add "java.exe" to the PATH
  33. echo.
  34. goto error
  35. :foundJavaHome
  36. if EXIST "%JAVA_HOME%\bin\java.exe" goto foundJavaExeFromJavaHome
  37. echo.
  38. echo ERROR: JAVA_HOME exists but does not point to a valid Java home
  39. echo folder. No "\bin\java.exe" file can be found there.
  40. echo.
  41. goto error
  42. :foundJavaExeFromJavaHome
  43. set JAVA_EXEC="%JAVA_HOME%\bin\java.exe"
  44. :OkJava
  45. goto run
  46. @REM ==== START RUN ====
  47. :run
  48. set PROJECT_HOME=%CD%
  49. @REM remove trailing backslash, see https://groups.google.com/d/msg/sonarqube/wi7u-CyV_tc/3u9UKRmABQAJ
  50. IF %PROJECT_HOME:~-1% == \ SET PROJECT_HOME=%PROJECT_HOME:~0,-1%
  51. %JAVA_EXEC% -Djava.awt.headless=true %SONAR_SCANNER_DEBUG_OPTS% %SONAR_SCANNER_OPTS% -cp "%SONAR_SCANNER_HOME%\lib\sonar-scanner-cli-${project.version}.jar" "-Dscanner.home=%SONAR_SCANNER_HOME%" "-Dproject.home=%PROJECT_HOME%" org.sonarsource.scanner.cli.Main %*
  52. if ERRORLEVEL 1 goto error
  53. goto end
  54. :error
  55. set ERROR_CODE=1
  56. @REM ==== END EXECUTION ====
  57. :end
  58. @REM set local scope for the variables with windows NT shell
  59. @endlocal & set ERROR_CODE=%ERROR_CODE%
  60. @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/
  61. goto exit
  62. :returncode
  63. exit /B %1
  64. :exit
  65. call :returncode %ERROR_CODE%