diff options
author | Zipeng WU <zipeng.wu@sonarsource.com> | 2022-08-11 11:28:34 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-08-11 20:03:47 +0000 |
commit | d60decc7c085fac107651dab2bf622f18de0679d (patch) | |
tree | 6f7ac7e9cadd373cfa0ee48f7671928be0328973 /sonar-application | |
parent | 682da493471ad008b5b5e72a6c0066ae474792b7 (diff) | |
download | sonarqube-d60decc7c085fac107651dab2bf622f18de0679d.tar.gz sonarqube-d60decc7c085fac107651dab2bf622f18de0679d.zip |
SONAR-17136 Add SONAR_JAVA_PATH env variable support for custom JRE on MacOS
Diffstat (limited to 'sonar-application')
-rwxr-xr-x | sonar-application/src/main/assembly/bin/macosx-universal-64/sonar.sh | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/sonar-application/src/main/assembly/bin/macosx-universal-64/sonar.sh b/sonar-application/src/main/assembly/bin/macosx-universal-64/sonar.sh index 2ef4624c57b..e18d6cd1949 100755 --- a/sonar-application/src/main/assembly/bin/macosx-universal-64/sonar.sh +++ b/sonar-application/src/main/assembly/bin/macosx-universal-64/sonar.sh @@ -2,8 +2,24 @@ APP_NAME="SonarQube" -# Java command location -JAVA_CMD="java" +# By default, java from the PATH is used, except if SONAR_JAVA_PATH env variable is set +findjava() { + if [ -z "${SONAR_JAVA_PATH}" ]; then + if ! command -v java 2>&1; then + echo "Java not found. Please make sure that the environmental variable SONAR_JAVA_PATH points to a Java executable" + exit 1 + fi + JAVA_CMD=java + else + if ! [ -x "${SONAR_JAVA_PATH}" ] || ! [ -f "${SONAR_JAVA_PATH}" ]; then + echo "File '${SONAR_JAVA_PATH}' is not executable. Please make sure that the environmental variable SONAR_JAVA_PATH points to a Java executable" + exit 1 + fi + JAVA_CMD="${SONAR_JAVA_PATH}" + fi +} + +findjava # Get the fully qualified path to the script case $0 in |