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 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/sh
  2. #
  3. # SonarScanner Startup Script for Unix
  4. #
  5. # Optional ENV vars:
  6. # SONAR_SCANNER_OPTS - Parameters passed to the Java VM when running the SonarScanner
  7. # SONAR_SCANNER_DEBUG_OPTS - Extra parameters passed to the Java VM for debugging
  8. # JAVA_HOME - Location of Java's installation
  9. real_path () {
  10. target=$1
  11. (
  12. while true; do
  13. cd "$(dirname "$target")"
  14. target=$(basename "$target")
  15. test -L "$target" || break
  16. target=$(readlink "$target")
  17. done
  18. echo "$(pwd -P)/$target"
  19. )
  20. }
  21. script_path=$(real_path "$0")
  22. sonar_scanner_home=$(dirname "$script_path")/..
  23. # make it fully qualified
  24. sonar_scanner_home=$(cd "$sonar_scanner_home" && pwd -P)
  25. jar_file=$sonar_scanner_home/lib/sonar-scanner-cli-${project.version}.jar
  26. # check that sonar_scanner_home has been correctly set
  27. if [ ! -f "$jar_file" ] ; then
  28. echo "File does not exist: $jar_file"
  29. echo "'$sonar_scanner_home' does not point to a valid installation directory: $sonar_scanner_home"
  30. exit 1
  31. fi
  32. use_embedded_jre=${use_embedded_jre}
  33. if [ "$use_embedded_jre" = true ]; then
  34. export JAVA_HOME=$sonar_scanner_home/jre
  35. fi
  36. if [ -n "$JAVA_HOME" ]
  37. then
  38. java_cmd="$JAVA_HOME/bin/java"
  39. else
  40. java_cmd="$(which java)"
  41. fi
  42. if [ -z "$java_cmd" -o ! -x "$java_cmd" ] ; then
  43. echo "Could not find 'java' executable in JAVA_HOME or PATH."
  44. exit 1
  45. fi
  46. project_home=$(pwd)
  47. #echo "Info: Using sonar-scanner at $sonar_scanner_home"
  48. #echo "Info: Using java at $java_cmd"
  49. #echo "Info: Using classpath $jar_file"
  50. #echo "Info: Using project $project_home"
  51. exec "$java_cmd" \
  52. -Djava.awt.headless=true \
  53. $SONAR_SCANNER_OPTS \
  54. $SONAR_SCANNER_DEBUG_OPTS \
  55. -classpath "$jar_file" \
  56. -Dscanner.home="$sonar_scanner_home" \
  57. -Dproject.home="$project_home" \
  58. org.sonarsource.scanner.cli.Main "$@"