Skip to content

Commit

Permalink
Fix sourceing sdkman
Browse files Browse the repository at this point in the history
  • Loading branch information
acetousk committed Aug 31, 2024
1 parent 293da82 commit 7b59558
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ command_exists() {
command -v "$1" &> /dev/null
}

# Function to source SDKMAN!
source_sdkman() {
if [ -d "$HOME/.sdkman" ]; then
source "$HOME/.sdkman/bin/sdkman-init.sh"
else
echo "SDKMAN! not found. Exiting..."
exit 1
fi
}

# Check if Java 11 Temurin is installed
JAVA_VERSION=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | cut -d'.' -f1-2)
if [[ "$JAVA_VERSION" != "11.0" ]]; then
Expand All @@ -44,9 +54,9 @@ if [ "$JAVA_INSTALLED" = false ] || [ "$GRADLE_INSTALLED" = false ]; then
if [ ! -d "$HOME/.sdkman" ]; then
echo "SDKMAN! not found. Installing SDKMAN!..."
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
source_sdkman
else
source "$HOME/.sdkman/bin/sdkman-init.sh"
source_sdkman
fi

# Install Java 11 Temurin if not installed
Expand Down Expand Up @@ -75,27 +85,27 @@ fi
echo "Java and Gradle setup complete."

# Rest of your script
if [ -f $MOQUI_HOME/moqui-plus-runtime.war ]; then
if [ -f "$MOQUI_HOME/moqui-plus-runtime.war" ]; then
echo "Using already built moqui-plus-runtime.war"
else
echo "cd into the $MOQUI_HOME directory"; START_PATH=$(pwd); cd $MOQUI_HOME
echo "cd into the $MOQUI_HOME directory"; START_PATH=$(pwd); cd "$MOQUI_HOME"

if [ ! -d $MOQUI_HOME/runtime ]; then echo "Getting runtime"; gradle $GRADLE_ARGS getRuntime; fi
if [ ! -d "$MOQUI_HOME/runtime" ]; then echo "Getting runtime"; gradle $GRADLE_ARGS getRuntime; fi
if [ "$RUN_LOCAL_SEARCH" == "true" ]; then
if [ "$search_name" != "elasticsearch" ]; then \
if [ ! -d $MOQUI_HOME/runtime/opensearch/bin ]; then echo "Installing OpenSearch"; gradle $GRADLE_ARGS downloadOpenSearch; fi
if [ ! -d "$MOQUI_HOME/runtime/opensearch/bin" ]; then echo "Installing OpenSearch"; gradle $GRADLE_ARGS downloadOpenSearch; fi
elif [ -d runtime/elasticsearch/bin ]; then \
if [ ! -d $MOQUI_HOME/runtime/elasticsearch/bin ]; then echo "Installing ElasticSearch"; gradle $GRADLE_ARGS downloadElasticSearch; fi
if [ ! -d "$MOQUI_HOME/runtime/elasticsearch/bin" ]; then echo "Installing ElasticSearch"; gradle $GRADLE_ARGS downloadElasticSearch; fi
fi;
fi

if [ -n "$GRADLE_COMMAND" ]; then echo "Running gradle $GRADLE_ARGS $GRADLE_COMMAND"; gradle $GRADLE_ARGS "$GRADLE_COMMAND"; fi

if [ $USE_HAZELCAST == "true" ]; then echo "Getting moqui-hazelcast"; gradle $GRADLE_ARGS getComponent -Pcomponent=moqui-hazelcast; fi
if [ "$USE_HAZELCAST" == "true" ]; then echo "Getting moqui-hazelcast"; gradle $GRADLE_ARGS getComponent -Pcomponent=moqui-hazelcast; fi
if [ -n "$COMPONENT" ]; then echo "Getting $COMPONENT"; gradle $GRADLE_ARGS getComponent -Pcomponent=$COMPONENT; fi
if [ -n "$COMPONENT_SET" ]; then echo "Getting $COMPONENT_SET"; gradle $GRADLE_ARGS getComponentSet -PcomponentSet=$COMPONENT_SET; fi

echo "Getting Dependencies"; gradle $GRADLE_ARGS getDepends
echo "Add runtime"; gradle $GRADLE_ARGS addRuntime
echo "Done"; cd $START_PATH
echo "Done"; cd "$START_PATH"
fi

0 comments on commit 7b59558

Please sign in to comment.