Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
build-uberjar 1.33 KiB
#! /bin/bash

# Generate the resources/version.properties file
version() {
    # Skip on CircleCI since this is interactive
    if [ ! $CI ]; then
        VERSION=$(./version)

        echo "Tagging this uberjar as version '$VERSION'"
        read -e -p "Is this OK? [y/n] " TAG_IS_OKAY_Y_OR_N

        if [ $TAG_IS_OKAY_Y_OR_N != "y" ]; then
            "Stopping now! Please check that you've pushed the correct tag to origin/master and try again. 😿"
            exit 1
        fi

        # Ok, now generate the appropriate version.properties file.
        echo "version=$VERSION" > resources/version.properties
    fi
}

frontend() {
    echo "Running 'npm install' to download javascript dependencies..." &&
    npm install &&

    echo "Running 'webpack -p' to assemble and minify frontend assets..." &&
    ./node_modules/webpack/bin/webpack.js -p
}

sample-dataset() {
    if [ -f resources/sample-dataset.db.mv.db ]; then
        echo "Sample Dataset already generated."
    else
        echo "Running 'lein generate-sample-dataset' to generate the sample dataset..."
        lein generate-sample-dataset
    fi
}

uberjar() {
    echo "Running 'lein uberjar'..."
    lein uberjar
}

all() {
    version && frontend && sample-dataset && uberjar
}

# Default to running all but let someone specify if desired
if [ $1 ]; then
    $1
else
    all
fi