Skip to content

Commit

Permalink
Uses custom plugin to publish zips to maven (opensearch-project#366)
Browse files Browse the repository at this point in the history
* Uses custom plugin to publish zips to maven

Signed-off-by: Clay Downs <[email protected]>

* Adds build.sh file

Signed-off-by: Clay Downs <[email protected]>

* Revises build.sh

Signed-off-by: Clay Downs <[email protected]>
  • Loading branch information
downsrob authored May 25, 2022
1 parent 948b2c1 commit 09f7930
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
24 changes: 24 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ apply plugin: 'opensearch.rest-test'
apply plugin: 'io.gitlab.arturbosch.detekt'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.kotlin.plugin.allopen'
apply plugin: 'opensearch.pluginzip'

configurations.all {
if (it.state != Configuration.State.UNRESOLVED) return
Expand Down Expand Up @@ -194,6 +195,29 @@ repositories {
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
}

publishing {
publications {
pluginZip(MavenPublication) { publication ->
pom {
name = opensearchplugin.name
description = opensearchplugin.description
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/index-management"
}
}
}
}
}
}

plugins.withId('java') {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11
}
Expand Down
82 changes: 82 additions & 0 deletions 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

0 comments on commit 09f7930

Please sign in to comment.