alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Play Framework/Scala example source code file (package)

This example Play Framework source code file (package) is included in my "Source Code Warehouse" project. The intent of this project is to help you more easily find Play Framework (and Scala) source code examples by using tags.

All credit for the original source code belongs to Play Framework; I'm just trying to make examples easier to find. (For my Scala work, see my Scala examples and tutorials.)

Play Framework tags/keywords

api, apidocsclone, crossbuild, gitbranch, optarg, play, play_version, publish, publishcmd, tag

The package Play Framework example source code

#! /bin/bash

# Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>

set -e

DIR=`dirname "$0"`

PUBLISH=1
TAG=1
CLEAN=0
PUBLISHCMD="publish-local-signed"
GITBRANCH=`git rev-parse --abbrev-ref HEAD`
CROSSBUILD="2.11.1"

usage() {
    echo "Usage:"
    echo "$0 -v <version> [ -hpt ] [ -a <apidocsclone> ] [ -c <scalaversions> ]"
    echo ""
    echo "  -v The version of Play to release"
    echo "  -h Display this help and exit"
    echo "  -p Publish the release"
    echo "  -t Tag the release"
    echo "  -n Don't do a clean first"
    echo "  -a Publish the API docs to the given clone of the API docs repository"
    echo "  -c Cross build against the comma separated list of versions, default: $CROSSBUILD"
    exit $1
}

while getopts ":hnptv:a:c:" opt
do
    case $opt in
        h)
            usage 0
            ;;
        p)
            PUBLISH=0
            PUBLISHCMD="publish-signed"
            ;;
        v)
            export PLAY_VERSION="$OPTARG"
            ;;
        a)
            APIDOCSCLONE="$OPTARG"
            ;;
        t)
            TAG=0
            ;;
        n)
            CLEAN=1
            ;;
        c)
            CROSSBUILD="$OPTARG"
            ;;
        :)
            echo "Option -$OPTARG requires an argument" >&2
            usage 1
            ;;
        *)
            echo "Invalid option: -$OPTARG" >&2
            usage 1
            ;;
    esac
done

if [ $OPTIND -le $# ]
then
    shift $(($OPTIND-1))
    echo "Invalid argument: $1"
    usage 1
fi

if [ -z "$PLAY_VERSION" ]
then
    echo "Play version not set" >&2
    usage 1
fi

if [ $PUBLISH -eq 0 ] 
then
    echo "This build will publish Play ${PLAY_VERSION}"
    if [ $TAG == 0 ]
    then
        echo "It will also tag the repository"
    fi
    if [ -n "$APIDOCSCLONE" ]
    then
        echo "It will also publish API docs to $APIDOCSCLONE"
    fi
    read -p "Are you sure you want to continue? [y/n] " CONFIRM
    if [ $CONFIRM != "y" ]
    then
        echo "Cancelling"
        exit
    fi
else
    echo "Building Play, but not publishing anything"
fi

if [ $CLEAN -eq 0 ]
then
    "$DIR/build" clean
fi

"$DIR/build" $PUBLISHCMD

for v in $(echo $CROSSBUILD | sed "s/,/ /")
do
    if [ -n "$v" ]
    then
        echo "Cross building Play against Scala $v"
        "$DIR/build" -Dscala.version=$v $PUBLISHCMD
    fi
done

if [ $TAG -eq 0 ]
then
    echo "Tagging..."
    git tag -a -s -m "Releasing $PLAY_VERSION" $PLAY_VERSION
    if [ $PUBLISH -eq 0 ]
    then
        git push origin $PLAY_VERSION
    fi
fi

if [ -n "$APIDOCSCLONE" ]
then
    echo "Updating api docs"

    OLDDIR=`pwd`
    cd $APIDOCSCLONE

    git reset --hard
    git fetch
    git checkout $GITBRANCH
    git merge origin/$GITBRANCH

    rm -r *
    cp -r "$OLDDIR/src/play-docs/target/scala-2.10/apidocs" api
    git add --all
    git commit -m "Publishing $PLAY_VERSION docs"
    git tag -a -m "Publishing $PLAY_VERSION docs" $PLAY_VERSION
    git reset --hard HEAD^

    if [ $PUBLISH -eq 0 ]
    then
        git push origin $PLAY_VERSION
    fi
    cd "$OLDDIR"
fi
    



Other Play Framework source code examples

Here is a short list of links related to this Play Framework package source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.