Skip to content

Commit 8ed1992

Browse files
committed
Zero installation/configuration but docker
1 parent 92321dd commit 8ed1992

2 files changed

Lines changed: 22 additions & 73 deletions

File tree

install-maven.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

prepare-docker-env.sh

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,19 @@ set -e
99
# Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
1010
# graphic logo is a trademark of OpenMRS Inc.
1111

12-
# This script is used to setup the development environment for the module.
13-
# It is run once when the project is first clone/created.
12+
# This script is used to setup the development environment for this module.
13+
# It should be run once when the project is first clone/created.
1414
# Downloads the required openmrs modules and installs them.
1515

1616
OPENMRS_SDK_PLUGIN="org.openmrs.maven.plugins:openmrs-sdk-maven-plugin"
1717
MODULES_DIR="required_modules"
1818

19-
#Extract project artifactId & version
19+
# Extract project artifactId & version
2020
OMOD_NAME=$(mvn help:evaluate -Dexpression=project.artifactId | grep -e '^[^\[]')
2121
OMOD_VERSION=$(mvn help:evaluate -Dexpression=project.version | grep -e '^[^\[]')
2222
echo "Current version: $OMOD_NAME-$OMOD_VERSION"
2323

24-
installMaven() {
25-
# Linux/unix
26-
# TODO: Find a better way to do this (No mvn install needed)
27-
sh install-maven.sh
28-
}
29-
30-
createEnvironmentVariablesFile() {
24+
create_environment_variables_file() {
3125
cat <<EOF >.env
3226
# OpenMRS core platform version.
3327
OPENMRS_CORE_VERSION=dev
@@ -47,48 +41,35 @@ OMOD_TARGET="$OMOD_NAME-$OMOD_VERSION.omod"
4741
EOF
4842
}
4943

50-
setupOpenmrsSDK() {
51-
# Setup SDK
52-
mvn ${OPENMRS_SDK_PLUGIN}:setup-sdk -DbatchAnswers=n -B
53-
#docker run -it -v maven-repo:/root/.m2 maven mvn ${OPENMRS_SDK_PLUGIN}:setup-sdk -DbatchAnswers=n -B
44+
prepare_modules_directory() {
45+
# prepare modules directory
46+
if [ -d "${MODULES_DIR}" ]; then
47+
echo "${MODULES_DIR} dir is already exists."
48+
# remove contents
49+
rm -rf "${MODULES_DIR:?}/"*
50+
else
51+
echo "Creating ${MODULES_DIR} directory..."
52+
mkdir -p "${MODULES_DIR}"
53+
fi
5454
}
5555

56-
downloadArtifacts() {
57-
# Prepare the modules dir
58-
if [ -d "${MODULES_DIR}" ]; then
59-
echo "${MODULES_DIR} dir is already exists."
60-
# Remove contents
61-
rm -rf "${MODULES_DIR:?}/"*
62-
else
63-
echo "Creating ${MODULES_DIR} directory..."
64-
mkdir -p "${MODULES_DIR}"
65-
fi
66-
56+
download_artifacts() {
6757
mkdir -p artifacts
68-
# Download modules
69-
#docker run -it openmrs/openmrs-core:dev-m1 mvn "$OPENMRS_SDK_PLUGIN":build-distro -Ddistro=module.properties -Ddir=artifacts -B
70-
mvn ${OPENMRS_SDK_PLUGIN}:build-distro -Ddistro=module.properties -Ddir=artifacts -B
58+
# download modules
59+
docker run --rm -w="/module" -v ${PWD}:/module openmrs/openmrs-core:dev mvn ${OPENMRS_SDK_PLUGIN}:build-distro -Ddistro=module.properties -Ddir=artifacts -B
60+
# copy downloaded modules to ${MODULES_DIR} directory
7161
cp -r artifacts/web/modules/* "${MODULES_DIR}"
72-
# Clean up artifacts
62+
# clean up artifacts
7363
rm -rf artifacts
7464
}
7565

7666
if [ -x "$(command -v docker)" ]; then
7767
installed_docker_version=$(docker --version)
7868
echo "Installed ${installed_docker_version}"
79-
echo "configuring openmrs sdk..."
80-
81-
# docker run openmrs/openmrs-core:dev
82-
# docker run openmrs/openmrs-core:dev mvn
83-
84-
if ! command -v mvn -v &>/dev/null; then
85-
echo "Installing maven..."
86-
installMaven
87-
fi
8869

89-
setupOpenmrsSDK
90-
downloadArtifacts
91-
createEnvironmentVariablesFile
70+
prepare_modules_directory
71+
download_artifacts
72+
create_environment_variables_file
9273
else
9374
printf "Please install Docker and re-run prepare script.\n"
9475
fi

0 commit comments

Comments
 (0)