summaryrefslogtreecommitdiff
path: root/run.sh
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2019-12-18 17:14:40 -0700
committermo khan <mo.khan@gmail.com>2020-01-24 10:58:33 -0700
commit3609544e5aefc366ce898eac3d63f2d22015a8dc (patch)
tree93415d2e07445662359a220db83764a54719b41a /run.sh
parentddfabcc48666a969ed927eb83619db3eef8ce893 (diff)
Load the approvate java and python if a SETUP_CMD is not specified
Diffstat (limited to 'run.sh')
-rwxr-xr-xrun.sh83
1 files changed, 28 insertions, 55 deletions
diff --git a/run.sh b/run.sh
index 82476b1..eeb948f 100755
--- a/run.sh
+++ b/run.sh
@@ -64,36 +64,6 @@ if [ "$COMMAND" = "test" -a $# -ne 3 ] ; then
exit 1
fi
-source $HOME/.asdf/asdf.sh
-
-# Switch to Python 3 if requesting
-case "$LM_PYTHON_VERSION" in
- "2"|"2.7")
- echo "using python $LM_PYTHON_VERSION"
- LICENSE_FINDER_CLI_OPTS="--python-version 2 $LICENSE_FINDER_CLI_OPTS"
- asdf shell python "$(asdf list python | awk '{ print $1 }' | grep '^2')"
- pip --version
- ;;
-
- "3")
- echo "switching to python $LM_PYTHON_VERSION"
- LICENSE_FINDER_CLI_OPTS="--python-version 3 $LICENSE_FINDER_CLI_OPTS"
- pip --version
- ;;
-
- "3.5")
- echo "switching to python $LM_PYTHON_VERSION"
- LICENSE_FINDER_CLI_OPTS="--python-version 3 $LICENSE_FINDER_CLI_OPTS"
- asdf shell python 3.5.9
- pip --version
- ;;
-
- *)
- echo "python version not supported: $LM_PYTHON_VERSION" >&2
- #exit 1
- ;;
-esac
-
# Run command
case "$COMMAND" in
test)
@@ -109,38 +79,50 @@ case "$COMMAND" in
shift
pushd $APP_PATH > /dev/null
+ if [ -n "$LM_PYTHON_VERSION" ]; then
+ asdf shell python "$LM_PYTHON_VERSION"
+ pip --version
+ MAJOR_VERSION=$(echo "$LM_PYTHON_VERSION" | cut -d'.' -f1)
+ case "$MAJOR_VERSION" in
+ "2")
+ echo "using python $LM_PYTHON_VERSION"
+ LICENSE_FINDER_CLI_OPTS="--python-version 2 $LICENSE_FINDER_CLI_OPTS"
+ ;;
+
+ "3")
+ echo "switching to python $LM_PYTHON_VERSION"
+ LICENSE_FINDER_CLI_OPTS="--python-version 3 $LICENSE_FINDER_CLI_OPTS"
+ ;;
+ *)
+ echo "python version not supported: $LM_PYTHON_VERSION" >&2
+ exit 1
+ ;;
+ esac
+ fi
+ if [ -n "$LM_JAVA_VERSION" ]; then
+ if [[ ${LM_JAVA_VERSION} = "11" ]]; then
+ asdf shell java adopt-openjdk-11.0.5+10
+ elif [[ ${LM_JAVA_VERSION} = "8" ]]; then
+ asdf shell java adopt-openjdk-8u232-b09
+ fi
+ fi
+ asdf current
if [[ -z "${SETUP_CMD}" ]]; then
asdf install
# Before running license_finder, we need to install dependencies for the project.
if test -f Gemfile ; then
- #if test -n "$rvm_recommended_ruby" ; then
- # Install the Ruby version RVM found in the project files
- # This always end in the cryptic "bash: Searching: command not found" error but Ruby is installed
- # So we ignore the error.
- #$($rvm_recommended_ruby) 2>/dev/null || true
- #rvm use .
- #bundler_version=$(grep -A1 "BUNDLED WITH" Gemfile.lock | tail -n 1)
- #gem install bundler -v "${bundler_version}" || gem install bundler
- # rvm pulls outdated gems
- # need this to update system bundler
- # We need to install the license_finder gem into this Ruby version too.
- gem install --no-document /opt/license-management/*.gem
- fi
-
# Ignore test and development dependencies.
license_finder ignored_groups add development
license_finder ignored_groups add test
bundle install --jobs $(nproc)
skip_prepare=true
fi
-
if test -f package.json; then
# Check is npm is being used
if [ -f package-lock.json ] && [ ! -f yarn.lock ] ; then
echo "Installing npm packages with npm ci"
npm ci
fi
-
# install via yarn
if [ ! -d node_modules ]; then
echo "Installing yarn packages"
@@ -148,7 +130,6 @@ case "$COMMAND" in
fi
skip_prepare=true
fi
-
if find . -name "*.go" -printf "found" -quit |grep found >/dev/null ; then
if [[ ( ! -f glide.lock ) && ( ! -f vendor/manifest ) && (! -f Gopkg.lock ) && (! -f go.mod ) ]]; then
echo "running go get"
@@ -160,19 +141,11 @@ case "$COMMAND" in
skip_prepare=true
fi
fi
-
- if [[ ${LM_JAVA_VERSION} = "11" ]]; then
- JAVA_HOME=/usr/lib/jvm/adoptopen_jdk11
- elif [[ ${LM_JAVA_VERSION} = "8" ]]; then
- JAVA_HOME=/usr/lib/jvm/oracle_jdk8
- fi
-
if test -f pom.xml ; then
# Install Java Maven dependencies.
mvn install ${MAVEN_CLI_OPTS:--DskipTests}
skip_prepare=true
fi
-
if test -f build.gradle ; then
gradle build ${GRADLE_CLI_OPTS:-x test}
skip_prepare=true