Permalink
Browse files

Merge pull request #3 from jsimone/master

Add support for arbitrary Play! versions
  • Loading branch information...
2 parents 1d55a56 + 06edf70 commit b32f9dad6639eefc62d88384bfe5cf1eccf9cade @jsimone jsimone committed Dec 15, 2011
Showing with 53 additions and 10 deletions.
  1. +13 −2 README.md
  2. +40 −8 bin/compile
View
@@ -35,14 +35,25 @@ Example usage:
The buildpack will detect your app as using the Play! framework if it has an `application.conf` in a `conf` directory. Your dependencies will be resolved using `play dependencies` and your app precompiled with `play precompile`. If you don't provide a Procfile the build pack will default to launching your app with `play run --%prod -Dprecompiled=true`.
+Play Versions
+-------------
+
+The buildpack will read the Play! version that your application expects from your dependencies.yml file. The version comes on the same line where you already declare a dependency on the Play! framework itself:
+
+ - play 1.2.4
+
+If you don't specify a version it will be defaulted for you and you'll see a warning message in your build output. It is a best practice to specify the version off the framework that you intend to use.
+
+Once your application is live you can upgrade the Play! version simply by changing the version in your dependencies.yml. If you don't specify a version and use the default version your application will not be updated when the default version is updated. This is so that you don't have to deal with your application being upgraded unexpectedly.
+
Hacking
-------
To use this buildpack, fork it on Github.  Push up changes to your fork, then create a test app with `--buildpack <your-github-url>` and push to it.
-For example one of the things that the build pack does is download and install the Play! framework that will be used to run your app. If you want to use a different version of the play framework place a tar.gz of the framework in a public location and then alter the line that sets this variable in the compile script to point there:
+For example one of the things that the build pack does is download and install the Play! framework that will be used to run your app. If you want to use a version of the framework other than those that are supported place a tar.gz of the framework in a public location and then alter the line that sets this variable in the compile script to point there:
- PLAY_URL="https://s3.amazonaws.com/heroku-jvm-langpack-play/play-heroku.tar.gz"
+ PLAY_URL="https://s3.amazonaws.com/heroku-jvm-langpack-play/play-heroku-$VER_TO_INSTALL.tar.gz"
This will alter the behaviour to pull down and install your chosen version of Play! rather than the default.
View
@@ -29,15 +29,47 @@ check_compile_status()
fi
}
-# Install Play! if not already
-if [ ! -d $PLAY_PATH ]; then
- PLAY_URL="https://s3.amazonaws.com/heroku-jvm-langpack-play/play-heroku.tar.gz"
-
- echo -n "-----> Installing Play!....."
- curl --silent --max-time 150 --location $PLAY_URL | tar xz
- check_compile_status
+install_play()
+{
+ VER_TO_INSTALL=$1
+ PLAY_URL="https://s3.amazonaws.com/heroku-jvm-langpack-play/play-heroku-$VER_TO_INSTALL.tar.gz"
+ PLAY_TAR_FILE="play-heroku.tar.gz"
+ echo "-----> Installing Play! $VER_TO_INSTALL....."
+ curl --silent --max-time 150 --location $PLAY_URL -o $PLAY_TAR_FILE
+ if [ ! -f $PLAY_TAR_FILE ]; then
+ echo "-----> Error downloading Play! framework. Please try again..."
+ exit 1
+ fi
+ if [ -z "`file $PLAY_TAR_FILE | grep gzip`" ]; then
+ echo "-----> Error installing Play! framework or unsupported Play! framework version specified. Please review Dev Center for a list of supported versions."
+ exit 1
+ fi
+ tar xzf $PLAY_TAR_FILE
+ rm $PLAY_TAR_FILE
chmod +x $PLAY_PATH/play
- echo " done"
+ echo "-----> done"
+}
+
+PLAY_VERSION=`grep 'play[ \t]*[0-9\.]' conf/dependencies.yml | sed -E -e 's/[ \t]*-[ \t]*play[ \t]*([1-9\.]*).*/\1/'`
+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 [ ! -d $PLAY_PATH ]; 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"

0 comments on commit b32f9da

Please sign in to comment.