This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
/
compile
executable file
·117 lines (94 loc) · 3.47 KB
/
compile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
# bin/compile <build-dir> <cache-dir>
# Parse args
BUILD_DIR=$1
CACHE_DIR=$2
BIN_DIR=$(cd $(dirname $0); pwd) # absolute path
# source in common functions
. $BIN_DIR/common.sh
silent --location http://heroku-jvm-common.s3.amazonaws.com/jvm-buildpack-common.tar.gz | tar xz
. bin/java
if [ -f ${CACHE_DIR}/system.properties ] && [ ! -f ${BUILD_DIR}/system.properties ]; then
cp ${CACHE_DIR}/system.properties ${BUILD_DIR}/system.properties
fi
if [ ! -d $CACHE_DIR ] && [ ! -f ${BUILD_DIR}/system.properties ]; then
echo "java.runtime.version=1.6" > ${BUILD_DIR}/system.properties;
fi
#create the cache dir if it doesn't exist
mkdir -p $CACHE_DIR
# install JDK
if [ -f ${BUILD_DIR}/system.properties ]; then
logger -p user.notice -t "slugc[$$]" "language_pack_java download_jdk"
LOGGER_FLAGS="$LOGGER_FLAGS download_jdk"
javaVersion=$(detect_java_version ${BUILD_DIR})
echo -n "-----> Installing OpenJDK ${javaVersion}..."
install_java ${BUILD_DIR} ${javaVersion}
echo "done"
cp ${BUILD_DIR}/system.properties ${CACHE_DIR}/
fi
PLAY_PATH=".play"
IVY_PATH=".ivy2"
# Change dir to handle relative paths
cd $BUILD_DIR
# Unpack cache
for DIR in $PLAY_PATH $IVY_PATH ; do
rm -rf $DIR
if [ -d $CACHE_DIR/$DIR ]; then
cp -r $CACHE_DIR/$DIR $DIR
fi
done
PLAY_VERSION=$(get_play_version conf/dependencies.yml)
DEFAULT_PLAY_VERSION="1.2.4"
VERSION_DECLARED=true
if [ -z "$PLAY_VERSION" ] ; then
PLAY_VERSION=$DEFAULT_PLAY_VERSION
VERSION_DECLARED=false
echo "-----> WARNING: Play! version not specified in dependencies.yml. Default version: $PLAY_VERSION being used...."
fi
# Install Play! or update the version
if [ ! -f $PLAY_PATH/play ]; then
install_play $PLAY_VERSION
else
INSTALLED_PLAY_VERSION=`cat $PLAY_PATH/framework/src/play/version`
if [ "$INSTALLED_PLAY_VERSION" != "$PLAY_VERSION" ] && $VERSION_DECLARED ; then
echo "-----> Updating Play! version. Previous version was $INSTALLED_PLAY_VERSION. Updating to $PLAY_VERSION..."
rm -rf $PLAY_PATH
install_play $PLAY_VERSION
fi
fi
PLAY_SETTINGS_URL="http://s3.amazonaws.com/heroku-jvm-langpack-play/ivysettings.xml"
echo -n "-----> Installing ivysettings.xml....."
if [ -f .ivy2/ivysettings.xml ]; then
rm .ivy2/ivysettings.xml
fi
curl --silent --max-time 10 --location $PLAY_SETTINGS_URL --create-dirs --output .ivy2/ivysettings.xml
echo " done"
# Build app
echo "-----> Building Play! application..."
$PLAY_PATH/play version | sed -u 's/^/ /'
# Precompile the Play! application at the root of $BUILD_DIR
APP_DIR=./
echo " Building Play! application at directory $APP_DIR"
DEPENDENCIES_CMD="$PLAY_PATH/play dependencies $APP_DIR --forProd --forceCopy --silent -Duser.home=$BUILD_DIR 2>&1"
echo " Resolving dependencies: $DEPENDENCIES_CMD"
eval "$DEPENDENCIES_CMD" | sed -u 's/^/ /'
check_compile_status
PRECOMPILE_CMD="$PLAY_PATH/play precompile $APP_DIR --silent 2>&1"
echo " Precompiling: $PRECOMPILE_CMD"
eval "$PRECOMPILE_CMD" | sed -u 's/^/ /'
check_compile_status
# Repack Play! framework into cache
mkdir -p $CACHE_DIR
for DIR in $PLAY_PATH $IVY_PATH ; do
rm -rf $CACHE_DIR/$DIR
cp -r $DIR $CACHE_DIR/$DIR
done
# Remove build time dependencies from slug
# (Note: runtime modules are copied to slug with --forceCopy option)
rm -fr $PLAY_PATH/modules
rm -fr $IVY_PATH
# Warn if no Procfile is present
if [ ! -f Procfile ]; then
echo "-----> No Procfile found. Will use the following default process: "
echo " play run --http.port=\$PORT \$PLAY_OPTS"
fi