Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses custom plugin to publish zips to maven #786

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions opensearch-observability/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,5 @@ local.properties

local-test
.local-*

/artifacts/
24 changes: 24 additions & 0 deletions opensearch-observability/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'idea'
apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.pluginzip'
apply plugin: 'opensearch.testclusters'
apply plugin: 'io.gitlab.arturbosch.detekt'
apply plugin: 'org.jetbrains.kotlin.jvm'
Expand All @@ -68,6 +69,29 @@ opensearchplugin {
extendedPlugins = ['opensearch-job-scheduler']
}

publishing {
publications {
pluginZip(MavenPublication) { publication ->
pom {
name = 'opensearch-observability'
description = 'OpenSearch Observability plugin'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
name = 'OpenSearch'
url = 'https://github.com/opensearch-project/observability'
}
}
}
}
}
}

allOpen {
annotation("org.opensearch.observability.util.OpenForTesting")
}
Expand Down
82 changes: 82 additions & 0 deletions opensearch-observability/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/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 "-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 version"
usage
exit 1
fi

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

mkdir -p $OUTPUT

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

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

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

./gradlew publishPluginZipPublicationToZipStagingRepository -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
mkdir -p $OUTPUT/maven/org/opensearch
cp -r ./build/local-staging-repo/org/opensearch/. $OUTPUT/maven/org/opensearch