LearnPAd/learnpad

View on GitHub
lp-content-analysis/build

Summary

Maintainability
Test Coverage
#!/usr/bin/env bash

### VARIABLES ###

# This is the directory path to your component
declare -r __COMPONENT_PATH__="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# This is the name of your component (must be the last part of ${__COMPONENT_PATH__}
declare -r __COMPONENT_NAME__="$( basename "${__COMPONENT_PATH__}" )"
# This is the path to your `out' directory
declare -r __OUT_PATH__="${__COMPONENT_PATH__}/out"
# These are path for the `start' and `stop' script that must be provided
declare -r __OUT_START_FILE__="${__OUT_PATH__}/start"
declare -r __OUT_STOP_FILE__="${__OUT_PATH__}/stop"
# This is a path to the optional file which list the needed dependencies to run the component
declare -r __OUT_RUNDEPS_FILE__="${__OUT_PATH__}/rundeps.txt"
# This is the path to the directory where you can optionally put some configuration files
declare -r __OUT_CONF_PATH__="${__OUT_PATH__}/etc"

# avoid deleting/re-downloading license files
## declare -r __MVN_PROFILE__="-Pkeep-license-files --batch-mode -Dhttps.protocols=TLSv1.2"
declare -r __MVN_PROFILE__="-Pkeep-license-files --batch-mode -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2"

declare __ARG_FLAG__="";
for arg in $*
do
    case ${arg} in
        "--dev")
            __ARG_FLAG__="dev";
            declare __MVN_PROFILES__="${__MVN_PROFILES__},dev"
            ;;
        "--review")
            __ARG_FLAG__="review";
            declare __MVN_PROFILES__="${__MVN_PROFILES__},review"
            ;;
        "--finalreview")
            __ARG_FLAG__="finalreview";
            declare __MVN_PROFILES__="${__MVN_PROFILES__},finalreview"
            ;;
        "--marche")
            __ARG_FLAG__="marche";
            declare __MVN_PROFILES__="${__MVN_PROFILES__},marche"
            ;;
    esac
done

### BUILD ###
function component_build() {
    rm -rf ${__OUT_PATH__}
    mvn ${__MVN_PROFILE__} clean
    # skip tests as we will do them in the component_test stage
    mvn ${__MVN_PROFILE__} package -Dmaven.test.skip=true
    cd lp-ca-ui
    ./build
    cd ..
}

### TEST ###
function component_test() {
    mvn ${__MVN_PROFILE__} test
}

### INSTALL ###
# This is where you need to publish material into the `out' directory
function component_install() {
    mkdir -p ${__OUT_PATH__}
    case "${__ARG_FLAG__}" in
    "finalreview")
            cp "scripts/start-finalreview" "${__OUT_START_FILE__}"
        ;;
    "marche")
            cp "scripts/start-marche" "${__OUT_START_FILE__}"
        ;;
    *)
            cp "scripts/start" "${__OUT_START_FILE__}"
        ;;
    esac
    cp "scripts/stop" "${__OUT_STOP_FILE__}"
    cp -r "target/lib/" "${__OUT_PATH__}/lib/"
    cp "target/lp-content-analysis.jar" "${__OUT_PATH__}/lp-content-analysis.jar"
    cp "target/config.properties" "${__OUT_PATH__}/config.properties"
    cp "target/configMarche.properties" "${__OUT_PATH__}/configMarche.properties"
    cp "target/configFinalReview.properties" "${__OUT_PATH__}/configFinalReview.properties"
    # There is no run dependencies for this component
    #cp <path_to>/rundeps.txt ${__OUT_RUNDEPS_FILE__}
    # These is no configuration file to copy
    #cp <path_to>/file.cfg ${__OUT_CONF_PATH__}/
    
    mkdir -p ${__OUT_PATH__}/lp-ca-ui/
    cp -r lp-ca-ui/out/* "${__OUT_PATH__}/lp-ca-ui/"

}

component_build && component_test && component_install