From 84c068ccd51af891702595c86f620fb91aafafe5 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 12 Apr 2022 23:53:11 +0000 Subject: [PATCH 1/2] Add new build scripts for subfolder structure Signed-off-by: Peter Zhu --- dashboards-notifications/scripts/build.sh | 82 --------------------- {notifications/scripts => scripts}/build.sh | 26 ++++--- 2 files changed, 16 insertions(+), 92 deletions(-) delete mode 100644 dashboards-notifications/scripts/build.sh rename {notifications/scripts => scripts}/build.sh (77%) diff --git a/dashboards-notifications/scripts/build.sh b/dashboards-notifications/scripts/build.sh deleted file mode 100644 index c6c9fff4..00000000 --- a/dashboards-notifications/scripts/build.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash - -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -set -ex - -function usage() { - echo "Usage: $0 [args]" - echo "" - echo "Arguments:" - echo -e "-v VERSION\t[Required] OpenSearch version." - echo -e "-q QUALIFIER\t[Optional] Version qualifier." - echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'." - echo -e "-p PLATFORM\t[Optional] Platform, ignored." - echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored." - echo -e "-o OUTPUT\t[Optional] Output path, default is 'artifacts'." - echo -e "-h help" -} - -while getopts ":h:v:q:s:o:p:a:" arg; do - case $arg in - h) - usage - exit 1 - ;; - v) - VERSION=$OPTARG - ;; - q) - QUALIFIER=$OPTARG - ;; - s) - SNAPSHOT=$OPTARG - ;; - o) - OUTPUT=$OPTARG - ;; - p) - PLATFORM=$OPTARG - ;; - a) - ARCHITECTURE=$OPTARG - ;; - :) - echo "Error: -${OPTARG} requires an argument" - usage - exit 1 - ;; - ?) - echo "Invalid option: -${arg}" - exit 1 - ;; - esac -done - -if [ -z "$VERSION" ]; then - echo "Error: You must specify the OpenSearch Dashboards version" - usage - exit 1 -fi - -[ -z "$OUTPUT" ] && OUTPUT=artifacts -[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER" - -mkdir -p $OUTPUT/plugins -# For hybrid plugin it actually resides in 'notificationsDashboards/dashboards-notifications' -PLUGIN_FOLDER=$(basename "$PWD") -PLUGIN_NAME=$(basename $(dirname "$PWD")) -# TODO: [CLEANUP] Needed OpenSearch Dashboards git repo to build the required modules for plugins -# This makes it so there is a dependency on having Dashboards pulled already. -cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins -echo "BUILD MODULES FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards && yarn osd bootstrap) -echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) -echo "COPY $PLUGIN_NAME.zip" -cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/ -rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER \ No newline at end of file diff --git a/notifications/scripts/build.sh b/scripts/build.sh similarity index 77% rename from notifications/scripts/build.sh rename to scripts/build.sh index 4c984167..10445e2b 100644 --- a/notifications/scripts/build.sh +++ b/scripts/build.sh @@ -70,19 +70,25 @@ fi mkdir -p $OUTPUT/maven mkdir -p $OUTPUT/plugins -cd notifications +# Either core or notifications subfolders +CURR_DIR=`basename $(pwd)` + +# Go to the first notifications folder, which holds the core folder and the second notifications folder +cd ../ ./gradlew publishToMavenLocal -PexcludeTests="**/SesChannelIT*" -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER ./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER -cd .. mkdir -p $OUTPUT/plugins -notifCoreZipPath=$(find . -path \*core/build/distributions/*.zip) -distributions="$(dirname "${notifCoreZipPath}")" -echo "COPY ${distributions}/*.zip" -cp ${distributions}/*.zip ./$OUTPUT/plugins +if [ "$CURR_DIR" = "core" ]; then + notifCoreZipPath=$(ls core/build/distributions/ | grep .zip) + cp -v core/build/distributions/$notifCoreZipPath ./$OUTPUT/plugins + +elif [ "$CURR_DIR" = "notifications" ]; then + notifCoreZipPath=$(ls notifications/build/distributions/ | grep .zip) + cp -v notifications/build/distributions/$notifCoreZipPath ./$OUTPUT/plugins -notifZipPath=$(find . -path \*notifications/build/distributions/*.zip) -distributions="$(dirname "${notifZipPath}")" -echo "COPY ${distributions}/*.zip" -cp ${distributions}/*.zip ./$OUTPUT/plugins \ No newline at end of file +else + echo "$CURR_DIR not exist!" + exit 1 +fi From 543d6caedb18d92b399cca6235da9a380adbd11b Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 13 Apr 2022 00:11:42 +0000 Subject: [PATCH 2/2] Remove scripts Signed-off-by: Peter Zhu --- scripts/build.sh | 94 ------------------------------------------------ 1 file changed, 94 deletions(-) delete mode 100644 scripts/build.sh diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100644 index 10445e2b..00000000 --- a/scripts/build.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash - -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -set -ex - -function usage() { - echo "Usage: $0 [args]" - echo "" - echo "Arguments:" - echo -e "-v VERSION\t[Required] OpenSearch version." - echo -e "-q QUALIFIER\t[Optional] Build qualifier." - echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'." - echo -e "-p PLATFORM\t[Optional] Platform, ignored." - echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored." - echo -e "-o OUTPUT\t[Optional] Output path, default is 'artifacts'." - echo -e "-h help" -} - -while getopts ":h:v:q:s:o:p:a:" arg; do - case $arg in - h) - usage - exit 1 - ;; - v) - VERSION=$OPTARG - ;; - q) - QUALIFIER=$OPTARG - ;; - s) - SNAPSHOT=$OPTARG - ;; - o) - OUTPUT=$OPTARG - ;; - p) - PLATFORM=$OPTARG - ;; - a) - ARCHITECTURE=$OPTARG - ;; - :) - echo "Error: -${OPTARG} requires an argument" - usage - exit 1 - ;; - ?) - echo "Invalid option: -${arg}" - exit 1 - ;; - esac -done - -if [ -z "$VERSION" ]; then - echo "Error: You must specify the OpenSearch version" - usage - exit 1 -fi - -[[ ! -z "$QUALIFIER" ]] && VERSION=$VERSION-$QUALIFIER -[[ "$SNAPSHOT" == "true" ]] && VERSION=$VERSION-SNAPSHOT -[ -z "$OUTPUT" ] && OUTPUT=artifacts - -mkdir -p $OUTPUT/maven -mkdir -p $OUTPUT/plugins - -# Either core or notifications subfolders -CURR_DIR=`basename $(pwd)` - -# Go to the first notifications folder, which holds the core folder and the second notifications folder -cd ../ -./gradlew publishToMavenLocal -PexcludeTests="**/SesChannelIT*" -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER -./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER - -mkdir -p $OUTPUT/plugins - -if [ "$CURR_DIR" = "core" ]; then - notifCoreZipPath=$(ls core/build/distributions/ | grep .zip) - cp -v core/build/distributions/$notifCoreZipPath ./$OUTPUT/plugins - -elif [ "$CURR_DIR" = "notifications" ]; then - notifCoreZipPath=$(ls notifications/build/distributions/ | grep .zip) - cp -v notifications/build/distributions/$notifCoreZipPath ./$OUTPUT/plugins - -else - echo "$CURR_DIR not exist!" - exit 1 -fi