Skip to content

Commit

Permalink
Add OpenSearch build script
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitkala committed Aug 25, 2021
1 parent 6946805 commit 88031ba
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 3 deletions.
24 changes: 21 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ import java.util.stream.Collectors
import org.opensearch.gradle.testclusters.OpenSearchCluster

buildscript {

ext {
opensearch_version = System.getProperty("opensearch_version", "1.1.0")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
opensearch_version = System.getProperty("opensearch.version", "1.1.0")
// Taken from https://github.com/opensearch-project/alerting/blob/main/build.gradle#L33
// 1.0.0 -> 1.0.0.0, and 1.0.0-SNAPSHOT -> 1.0.0.0-SNAPSHOT
opensearch_build = opensearch_version.replaceAll(/(\.\d)([^\d]*)$/, '$1.0$2')
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
kotlin_version = System.getProperty("kotlin.version", "1.3.72")

}

repositories {
Expand All @@ -47,12 +54,16 @@ buildscript {
}
}


plugins {
id 'nebula.ospackage' version "8.3.0"
id "com.dorongold.task-tree" version "1.5"
}

allprojects {
group = "org.opensearch"
version = "${opensearch_version}"
}

apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'idea'
Expand Down Expand Up @@ -91,7 +102,7 @@ dependencies {
compile "org.jetbrains:annotations:13.0"
compile "com.github.seancfoley:ipaddress:5.3.3"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5"
compile "org.opensearch:common-utils:${version}"
compile "org.opensearch:common-utils:${common_utils_version}"

testCompile "org.opensearch.test:framework:${opensearch_version}"
testImplementation "org.assertj:assertj-core:3.17.2"
Expand All @@ -104,6 +115,7 @@ repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
jcenter()
}

compileKotlin {
Expand Down Expand Up @@ -132,6 +144,12 @@ opensearchplugin {
classname = "org.opensearch.replication.ReplicationPlugin"
}

artifacts {
if (!isSnapshot) {
archives sourcesJar
archives javadocJar
}
}

javadoc.enabled = false
licenseHeaders.enabled = false
Expand Down
68 changes: 68 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

# Copyright OpenSearch Contributors.
# SPDX-License-Identifier: Apache-2.0

set -ex

function usage() {
echo "Usage: $0 [args]"
echo ""
echo "Arguments:"
echo -e "-v VERSION\t[Required] OpenSearch version."
echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'."
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:s:o:a:" arg; do
case $arg in
h)
usage
exit 1
;;
v)
VERSION=$OPTARG
;;
s)
SNAPSHOT=$OPTARG
;;
o)
OUTPUT=$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

[[ "$SNAPSHOT" == "true" ]] && VERSION=$VERSION-SNAPSHOT
[ -z "$OUTPUT" ] && OUTPUT=artifacts

mkdir -p $OUTPUT/plugins

./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT

zipPath=$(find . -path \*build/distributions/*.zip)
distributions="$(dirname "${zipPath}")"

echo "COPY ${distributions}/*.zip"
cp ${distributions}/*.zip ./$OUTPUT/plugins

./gradlew publishToMavenLocal -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT

0 comments on commit 88031ba

Please sign in to comment.