Skip to content

Commit 888cf7b

Browse files
Add local staging maven jars publishing (#27)
Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
1 parent 4fc51af commit 888cf7b

File tree

2 files changed

+93
-3
lines changed

2 files changed

+93
-3
lines changed

build.gradle

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ buildscript {
2020
repositories {
2121
mavenLocal()
2222
mavenCentral()
23-
maven { url "https://plugins.gradle.org/m2/" }
2423
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
24+
maven { url "https://plugins.gradle.org/m2/" }
2525
}
2626

2727
dependencies {
@@ -32,7 +32,6 @@ buildscript {
3232

3333
plugins {
3434
id 'java'
35-
3635
}
3736

3837
repositories {
@@ -43,7 +42,7 @@ repositories {
4342
}
4443

4544
allprojects {
46-
group 'org.opensearch.plugin'
45+
group 'org.opensearch'
4746
version = opensearch_version.tokenize('-')[0] + '.0'
4847
if (buildVersionQualifier) {
4948
version += "-${buildVersionQualifier}"
@@ -92,6 +91,10 @@ publishing {
9291
}
9392
}
9493
repositories {
94+
maven {
95+
name = 'staging'
96+
url = "${rootProject.buildDir}/local-staging-repo"
97+
}
9598
maven {
9699
name = "Snapshots"
97100
url = "https://aws.oss.sonatype.org/content/repositories/snapshots"

scripts/build.sh

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
# Copyright OpenSearch Contributors
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# The OpenSearch Contributors require contributions made to
7+
# this file be licensed under the Apache-2.0 license or a
8+
# compatible open source license.
9+
10+
set -ex
11+
12+
function usage() {
13+
echo "Usage: $0 [args]"
14+
echo ""
15+
echo "Arguments:"
16+
echo -e "-v VERSION\t[Required] OpenSearch version."
17+
echo -e "-q QUALIFIER\t[Optional] Version qualifier."
18+
echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'."
19+
echo -e "-p PLATFORM\t[Optional] Platform, ignored."
20+
echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored."
21+
echo -e "-o OUTPUT\t[Optional] Output path, default is 'artifacts'."
22+
echo -e "-h help"
23+
}
24+
25+
while getopts ":h:v:q:s:o:p:a:" arg; do
26+
case $arg in
27+
h)
28+
usage
29+
exit 1
30+
;;
31+
v)
32+
VERSION=$OPTARG
33+
;;
34+
q)
35+
QUALIFIER=$OPTARG
36+
;;
37+
s)
38+
SNAPSHOT=$OPTARG
39+
;;
40+
o)
41+
OUTPUT=$OPTARG
42+
;;
43+
p)
44+
PLATFORM=$OPTARG
45+
;;
46+
a)
47+
ARCHITECTURE=$OPTARG
48+
;;
49+
:)
50+
echo "Error: -${OPTARG} requires an argument"
51+
usage
52+
exit 1
53+
;;
54+
?)
55+
echo "Invalid option: -${arg}"
56+
exit 1
57+
;;
58+
esac
59+
done
60+
61+
if [ -z "$VERSION" ]; then
62+
echo "Error: You must specify the OpenSearch version"
63+
usage
64+
exit 1
65+
fi
66+
67+
[[ ! -z "$QUALIFIER" ]] && VERSION=$VERSION-$QUALIFIER
68+
[[ "$SNAPSHOT" == "true" ]] && VERSION=$VERSION-SNAPSHOT
69+
[ -z "$OUTPUT" ] && OUTPUT=artifacts
70+
71+
mkdir -p $OUTPUT
72+
73+
./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
74+
75+
zipPath=$(find . -path \*build/distributions/*.zip)
76+
distributions="$(dirname "${zipPath}")"
77+
78+
echo "COPY ${distributions}/*.zip"
79+
mkdir -p $OUTPUT/plugins
80+
cp ${distributions}/*.zip ./$OUTPUT/plugins
81+
82+
# Publish plugin zips to maven
83+
./gradlew publishToMavenLocal -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
84+
./gradlew publishAllPublicationsToStagingRepository -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
85+
./gradlew publishPluginZipPublicationToZipStagingRepository -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
86+
mkdir -p $OUTPUT/maven/org/opensearch
87+
cp -r ./build/local-staging-repo/org/opensearch/. $OUTPUT/maven/org/opensearch

0 commit comments

Comments
 (0)