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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/sh
  2. #
  3. # SonarQube Runner Startup Script for Unix
  4. #
  5. # Optional ENV vars:
  6. # SONAR_RUNNER_OPTS - Parameters passed to the Java VM when running Sonar
  7. # JAVA_HOME - Location of Java's installation
  8. # The following notice only apply to real_path function copied from
  9. # https://sites.google.com/site/jdisnard/realpath
  10. # Copyright 2010 Jon Disnard. All rights reserved.
  11. #
  12. # Redistribution and use in source and binary forms, with or without modification, are
  13. # permitted provided that the following conditions are met:
  14. #
  15. # 1. Redistributions of source code must retain the above copyright notice, this list of
  16. # conditions and the following disclaimer.
  17. #
  18. # 2. Redistributions in binary form must reproduce the above copyright notice, this list
  19. # of conditions and the following disclaimer in the documentation and/or other materials
  20. # provided with the distribution.
  21. #
  22. # THIS SOFTWARE IS PROVIDED BY Jon Disnard ``AS IS'' AND ANY EXPRESS OR IMPLIED
  23. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  24. # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
  25. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  26. # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  27. # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  28. # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  29. # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  30. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. #
  32. # The views and conclusions contained in the software and documentation are those of the
  33. # authors and should not be interpreted as representing official policies, either expressed
  34. # or implied, of Jon Disnard.
  35. real_path () {
  36. target=$1
  37. (
  38. while true; do
  39. cd "$(dirname "$target")"
  40. target=$(basename "$target")
  41. link=$(readlink "$target")
  42. test "$link" || break
  43. target=$link
  44. done
  45. echo "$(pwd -P)/$target"
  46. )
  47. }
  48. echo WARN: 'sonar-runner' script is deprecated. Please use 'sonar-scanner' instead.
  49. script_path="$0"
  50. if [ -h "$script_path" ] ; then
  51. # resolve recursively symlinks
  52. script_path=$(real_path "$script_path")
  53. fi
  54. sonar_runner_home=$(dirname "$script_path")/..
  55. # make it fully qualified
  56. sonar_runner_home=$(cd "$sonar_runner_home" && pwd)
  57. # check that the sonar_runner_home has been correctly set
  58. if [ ! -f "$sonar_runner_home/lib/sonar-scanner-cli-${project.version}.jar" ] ; then
  59. echo '$sonar_runner_home' does not point to a valid installation directory: $sonar_runner_home
  60. exit 1
  61. fi
  62. if [ -n "$JAVA_HOME" ]
  63. then
  64. java_cmd="$JAVA_HOME/bin/java"
  65. else
  66. java_cmd="$(which java)"
  67. fi
  68. if [ -n "$SONAR_RUNNER_OPTS" ] ;
  69. then
  70. echo WARN: '$SONAR_RUNNER_OPTS' is deprecated. Please use '$SONAR_SCANNER_OPTS' instead.
  71. if [ -z "$SONAR_SCANNER_OPTS" ] ; then
  72. SONAR_SCANNER_OPTS=$SONAR_RUNNER_OPTS
  73. fi
  74. fi
  75. jar_file=${sonar_runner_home}/lib/sonar-scanner-cli-${project.version}.jar
  76. project_home=$(pwd)
  77. #echo "Info: Using sonar-runner at $sonar_runner_home"
  78. #echo "Info: Using java at $java_cmd"
  79. #echo "Info: Using classpath $jar_file"
  80. #echo "Info: Using project $project_home"
  81. exec "$java_cmd" \
  82. -Djava.awt.headless=true \
  83. $SONAR_SCANNER_OPTS \
  84. -classpath "$jar_file" \
  85. -Dscanner.home="$sonar_runner_home" \
  86. -Dproject.home="$project_home" \
  87. org.sonarsource.scanner.cli.Main "$@"