Skip to content

Commit

Permalink
Update buildOnJdk.sh similar to those on mondrian. No longer need to
Browse files Browse the repository at this point in the history
edit the script in a build environment, provided that you set
environment variables JAVA_HOME_xx.


git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@521 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Mar 7, 2012
1 parent e97625c commit 57abe2c
Showing 1 changed file with 75 additions and 9 deletions.
84 changes: 75 additions & 9 deletions buildOnJdk.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
#
# $Id$
#
Expand Down Expand Up @@ -30,17 +31,82 @@
jdkVersion=$1
shift

# If you are building olap4j 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 olap4j 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 olap4j's
# source code under different JDKs. You will need to do one of the following:
#
# 1. Specify environment variables JAVA_HOME_15, JAVA_HOME_16 and JAVA_HOME_17
# before invoking 'ant'.
#
# 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.
#
# 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.
# 3. Customize this method with the correct JDK location.
#
#case "$jdkVersion" in
#(*) export JAVA_HOME=/usr/lib/jvm/${jdkVersion};;
#esac
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

if [ ! -d "$JAVA_HOME" ]; then
echo "$0: Invalid JAVA_HOME $JAVA_HOME; skipping compile."
Expand Down

0 comments on commit 57abe2c

Please sign in to comment.