Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MONDRIAN: fix for CM-88, CM-102, contributed by Mat Lowery:
Made changes to bat and sh files so that: * use a common set of steps to find a suitable java launcher * can be lauched from outside of their home folder * can be launched from folders with spaces * are compatible with solaris (use of backquotes instead of dollar parathesis) [git-p4: depot-paths = "//open/mondrian/": change = 13042]
- Loading branch information
Will Gorman
committed
Sep 15, 2009
1 parent
9c003d0
commit 0b45c8c
Showing
4 changed files
with
153 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
rem --------------------------------------------------------------------------- | ||
rem Finds a suitable Java | ||
rem | ||
rem Looks in well-known locations to find a suitable Java then sets two | ||
rem environment variables for use in other bat files. The two environment | ||
rem variables are: | ||
rem | ||
rem * _PENTAHO_JAVA_HOME - absolute path to Java home | ||
rem * _PENTAHO_JAVA - absolute path to Java launcher (e.g. java.exe) | ||
rem | ||
rem The order of the search is as follows: | ||
rem | ||
rem 1. environment variable PENTAHO_JAVA_HOME - path to Java home | ||
rem 2. environment variable JAVA_HOME - path to Java home | ||
rem 3. environment variable JRE_HOME - path to Java home | ||
rem 4. argument #1 - path to Java home | ||
rem | ||
rem If a suitable Java is found at one of these locations, then | ||
rem _PENTAHO_JAVA_HOME is set to that location and _PENTAHO_JAVA is set to the | ||
rem absolute path of the Java launcher at that location. If none of these | ||
rem locations are suitable, then _PENTAHO_JAVA_HOME is set to empty string and | ||
rem _PENTAHO_JAVA is set to java.exe. | ||
rem | ||
rem Finally, there is one final optional environment variable: PENTAHO_JAVA. | ||
rem If set, this value is used in the construction of _PENTAHO_JAVA. If not | ||
rem set, then the value java.exe is used. | ||
rem --------------------------------------------------------------------------- | ||
|
||
if not "%PENTAHO_JAVA%" == "" goto gotPentahoJava | ||
set __LAUNCHER=java.exe | ||
goto checkPentahoJavaHome | ||
|
||
:gotPentahoJava | ||
set __LAUNCHER=%PENTAHO_JAVA% | ||
goto checkPentahoJavaHome | ||
|
||
:checkPentahoJavaHome | ||
if not "%PENTAHO_JAVA_HOME%" == "" goto gotPentahoJavaHome | ||
if not "%JAVA_HOME%" == "" goto gotJdkHome | ||
if not "%JRE_HOME%" == "" goto gotJreHome | ||
goto tryValueFromCaller | ||
|
||
:gotPentahoJavaHome | ||
echo DEBUG: Using PENTAHO_JAVA_HOME | ||
set _PENTAHO_JAVA_HOME=%PENTAHO_JAVA_HOME% | ||
set _PENTAHO_JAVA=%_PENTAHO_JAVA_HOME%\bin\%__LAUNCHER% | ||
goto end | ||
|
||
:gotJdkHome | ||
echo DEBUG: Using JAVA_HOME | ||
set _PENTAHO_JAVA_HOME=%JAVA_HOME% | ||
set _PENTAHO_JAVA=%_PENTAHO_JAVA_HOME%\bin\%__LAUNCHER% | ||
goto end | ||
|
||
:gotJreHome | ||
echo DEBUG: Using JRE_HOME | ||
set _PENTAHO_JAVA_HOME=%JRE_HOME% | ||
set _PENTAHO_JAVA=%_PENTAHO_JAVA_HOME%\bin\%__LAUNCHER% | ||
goto end | ||
|
||
:tryValueFromCaller | ||
if not !%1!==!! goto gotValueFromCaller | ||
goto :gotPath | ||
|
||
:gotValueFromCaller | ||
echo DEBUG: Using value (%~1) from calling script | ||
set _PENTAHO_JAVA_HOME=%~1 | ||
set _PENTAHO_JAVA=%_PENTAHO_JAVA_HOME%\bin\%__LAUNCHER% | ||
goto end | ||
|
||
:gotPath | ||
echo WARNING: Using java from path | ||
set _PENTAHO_JAVA_HOME= | ||
set _PENTAHO_JAVA=%__LAUNCHER% | ||
|
||
goto end | ||
|
||
:end | ||
|
||
echo DEBUG: _PENTAHO_JAVA_HOME=%_PENTAHO_JAVA_HOME% | ||
echo DEBUG: _PENTAHO_JAVA=%_PENTAHO_JAVA% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/sh | ||
# ----------------------------------------------------------------------------- | ||
# Finds a suitable Java | ||
# | ||
# Looks in well-known locations to find a suitable Java then sets two | ||
# environment variables for use in other script files. The two environment | ||
# variables are: | ||
# | ||
# * _PENTAHO_JAVA_HOME - absolute path to Java home | ||
# * _PENTAHO_JAVA - absolute path to Java launcher (e.g. java) | ||
# | ||
# The order of the search is as follows: | ||
# | ||
# 1. environment variable PENTAHO_JAVA_HOME - path to Java home | ||
# 2. environment variable JAVA_HOME - path to Java home | ||
# 3. environment variable JRE_HOME - path to Java home | ||
# 4. argument #1 - path to Java home | ||
# | ||
# If a suitable Java is found at one of these locations, then | ||
# _PENTAHO_JAVA_HOME is set to that location and _PENTAHO_JAVA is set to the | ||
# absolute path of the Java launcher at that location. If none of these | ||
# locations are suitable, then _PENTAHO_JAVA_HOME is set to empty string and | ||
# _PENTAHO_JAVA is set to java. | ||
# | ||
# Finally, there is one final optional environment variable: PENTAHO_JAVA. | ||
# If set, this value is used in the construction of _PENTAHO_JAVA. If not | ||
# set, then the value java is used. | ||
# ----------------------------------------------------------------------------- | ||
|
||
setPentahoJava() { | ||
if [ -n "$PENTAHO_JAVA" ]; then | ||
__LAUNCHER="$PENTAHO_JAVA" | ||
else | ||
__LAUNCHER="java" | ||
fi | ||
if [ -n "$PENTAHO_JAVA_HOME" ]; then | ||
echo "DEBUG: Using PENTAHO_JAVA_HOME" | ||
_PENTAHO_JAVA_HOME="$PENTAHO_JAVA_HOME" | ||
_PENTAHO_JAVA="$_PENTAHO_JAVA_HOME"/bin/$__LAUNCHER | ||
elif [ -n "$JAVA_HOME" ]; then | ||
echo "DEBUG: Using JAVA_HOME" | ||
_PENTAHO_JAVA_HOME="$JAVA_HOME" | ||
_PENTAHO_JAVA="$_PENTAHO_JAVA_HOME"/bin/$__LAUNCHER | ||
elif [ -n "$JRE_HOME" ]; then | ||
echo "DEBUG: Using JRE_HOME" | ||
_PENTAHO_JAVA_HOME="$JRE_HOME" | ||
_PENTAHO_JAVA="$_PENTAHO_JAVA_HOME"/bin/$__LAUNCHER | ||
elif [ -n "$1" ] && [ -x "$1"/bin/$__LAUNCHER ]; then | ||
echo "DEBUG: Using value ($1) from calling script" | ||
_PENTAHO_JAVA_HOME="$1" | ||
_PENTAHO_JAVA="$_PENTAHO_JAVA_HOME"/bin/$__LAUNCHER | ||
else | ||
echo "WARNING: Using java from path" | ||
_PENTAHO_JAVA_HOME= | ||
_PENTAHO_JAVA=$__LAUNCHER | ||
fi | ||
echo "DEBUG: _PENTAHO_JAVA_HOME=$_PENTAHO_JAVA_HOME" | ||
echo "DEBUG: _PENTAHO_JAVA=$_PENTAHO_JAVA" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters