Skip to content

Commit 6e373a7

Browse files
authored
adding custom plugin to upload ad zip to maven (opensearch-project#594)
Signed-off-by: Amit Galitzky <amgalitz@amazon.com>
1 parent 0bd6e0e commit 6e373a7

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

build.gradle

+24
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ apply plugin: 'opensearch.testclusters'
9090
apply plugin: 'base'
9191
apply plugin: 'jacoco'
9292
apply plugin: 'eclipse'
93+
apply plugin: 'opensearch.pluginzip'
9394

9495
ext {
9596
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
@@ -144,6 +145,29 @@ configurations {
144145
}
145146
}
146147

148+
publishing {
149+
publications {
150+
pluginZip(MavenPublication) { publication ->
151+
pom {
152+
name = opensearchplugin.name
153+
description = opensearchplugin.description
154+
licenses {
155+
license {
156+
name = "The Apache License, Version 2.0"
157+
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
158+
}
159+
}
160+
developers {
161+
developer {
162+
name = "OpenSearch"
163+
url = "https://github.com/opensearch-project/anomaly-detection"
164+
}
165+
}
166+
}
167+
}
168+
}
169+
}
170+
147171
tasks.named('forbiddenApisMain').configure {
148172
// Only enable limited check because AD code has too many violations.
149173
replaceSignatureFiles 'jdk-signatures'

scripts/build.sh

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

0 commit comments

Comments
 (0)