Skip to content

Commit

Permalink
MONDRIAN: buildOnJdk.sh now uses JAVA_HOME_15, JAVA_HOME_16 and JAVA_…
Browse files Browse the repository at this point in the history
…HOME_17

    environment variables, if present. This means that the script does not need
    to be modified in a build environment, as long as those variables are set.
    Then it looks into the machine-specific install locations. Finally, one can
    customize where it looks for JDKs. If no valid JDK is found, uses the
    incoming JAVA_HOME, and ant will politely no-op if it is not the version it
    needs.

[git-p4: depot-paths = "//open/mondrian/": change = 14994]
  • Loading branch information
julianhyde committed Mar 7, 2012
1 parent 9395398 commit d3fb59b
Showing 1 changed file with 81 additions and 46 deletions.
127 changes: 81 additions & 46 deletions buildOnJdk.sh
Expand Up @@ -7,62 +7,97 @@
#
# For example:
# buildOnJdk.sh jdk1.6 compile.java
########################################################################

jdkVersion=$1
shift

########################################################################
# If you are building Mondrian for a single JDK (most likely the
# case), leave the following lines commented.
# Version number without jdk prefix. E.g. '1.6'.
versionSansJdk=`echo "${jdkVersion}" | sed 's/jdk\([0-9]\.[0-9]\)/\1/'`

# Chooses a JAVA_HOME to match the required JDK version.
#
# If you are building Mondrian for a single JDK (most likely the case), it
# doesn't matter if this method cannot find a valid JAVA_HOME for the JDK
# version. It will keep the existing JAVA_HOME, ant will report that the JDK
# version is not the one required, and will not compile any files. You will
# still end up with a valid build for all the classes needed by your JDK
# version.
#
# If you are building a release, you must compile different parts of Mondrian's
# source code under different JDKs. You will need to do one of the following:
#
# If you are building a release, you will need to compile different
# parts of Mondrian's source code under different JDKs. Uncomment the
# following lines to ensure that JAVA_HOME is assigned correctly for
# each JDK version.
# 1. Specify environment variables JAVA_HOME_15, JAVA_HOME_16 and JAVA_HOME_17
# before invoking 'ant'.
#
########################################################################
#case "$jdkVersion" in
#(*) export JAVA_HOME=/usr/lib/jvm/${jdkVersion};;
#esac
# 2. Install a JDK in (or create a symbolic link as) one of the standard
# locations: /usr/lib/jvm/jdk1.x on Linux/Unix/Cygwin; or
# /System/Library/Frameworks/JavaVM.framework/Versions/1.x/Home on MacOS.
#
#case $(uname) in
#Darwin)
# JDK_VERSION=`echo "${jdkVersion}" | sed 's/jdk\([0-9]\.[0-9]\)/\1/'`
# export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JDK_VERSION}/Home;;
#*)
# export JAVA_HOME=/usr/lib/jvm/${jdkVersion};;
#esac
########################################################################
# From this point, you don't need to modify anything... we hope.
# 3. Customize this method with the correct JDK location.
#
function chooseJavaHome() {
# If JAVA_HOME_xx is specified in the environment, use it.
case "$jdkVersion" in
(jdk1.5)
if [ -d "$JAVA_HOME_15" ]; then
export JAVA_HOME="$JAVA_HOME_15"
return
fi
;;
(jdk1.6)
if [ -d "$JAVA_HOME_16" ]; then
export JAVA_HOME="$JAVA_HOME_16"
return
fi
;;
(jdk1.7)
if [ -d "$JAVA_HOME_17" ]; then
export JAVA_HOME="$JAVA_HOME_17"
return
fi
;;
esac

# 2. Look in default location based on the operating system and JDK
# version. If the directory exists, we presume that it is a valid JDK, and
# override JAVA_HOME.
defaultJavaHome=
case $(uname) in
(Darwin)
defaultJavaHome=/System/Library/Frameworks/JavaVM.framework/Versions/${versionSansJdk}/Home;;
(*)
defaultJavaHome=/usr/lib/jvm/${jdkVersion};;
esac

if [ -d "$defaultJavaHome" ]; then
export JAVA_HOME="$defaultJavaHome"
return
fi

# 3. If JDK is installed in a non-standard location, customize here.
#
#case ${jdkVersion} in
#(jdk1.5) export JAVA_HOME=...; return ;;
#(jdk1.6) export JAVA_HOME=...; return ;;
#(jdk1.7) export JAVA_HOME=...; return ;;
#esac

# 4. Leave JAVA_HOME unchanged. If it does not match the required version,
# ant will no-op.
}

chooseJavaHome

########################################################################
# Validate that JAVA_HOME exists
if [ ! -d $JAVA_HOME ]; then
echo "$0: Invalid JAVA_HOME $JAVA_HOME; skipping compile."
exit 1
if [ ! -d "$JAVA_HOME" ]; then
echo "$0: Invalid JAVA_HOME $JAVA_HOME; skipping compile."
exit 1
fi

########################################################################
# Setting the PATH env variable
export PATH=$JAVA_HOME/bin:$PATH

########################################################################
# Validating that Ant is present
if [ ! -f "/opt/ant1.7/bin/ant" ]; then
ANT_BIN=`which ant`
if [ -z "$ANT_BIN" ]; then
echo "$0: Unable to locate ant binary; skipping compile."
exit 1
else
echo Using JAVA_HOME: $JAVA_HOME
echo Using Ant arguments: -Drequested.java.version="$jdkVersion" $@
$ANT_BIN -Drequested.java.version="$jdkVersion" "$@"
fi
else
echo Using JAVA_HOME: $JAVA_HOME
echo Using Ant arguments: -Drequested.java.version="$jdkVersion" $@
/opt/ant1.7/bin/ant -Drequested.java.version="$jdkVersion" "$@"
fi
echo Using JAVA_HOME: $JAVA_HOME
echo Using Ant arguments: -Drequested.java.version="$jdkVersion" $@

ant -Drequested.java.version="$jdkVersion" "$@"

########################################################################
# End buildOnJdk.sh

0 comments on commit d3fb59b

Please sign in to comment.