From 8ef66c787e53aa9759d9d886b4120d562a6d9513 Mon Sep 17 00:00:00 2001 From: Subhobrata Dey Date: Mon, 3 Jun 2024 18:58:05 +0000 Subject: [PATCH] enable publishing of alerting-spi jar (#1562) Signed-off-by: Subhobrata Dey --- .github/workflows/maven-publish.yml | 1 + spi/build.gradle | 77 ++++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 31e21d66b..75f22834a 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -38,4 +38,5 @@ jobs: export SONATYPE_PASSWORD=$(aws secretsmanager get-secret-value --secret-id maven-snapshots-password --query SecretString --output text) echo "::add-mask::$SONATYPE_USERNAME" echo "::add-mask::$SONATYPE_PASSWORD" + ./gradlew publishShadowPublicationToSnapshotsRepository ./gradlew publishPluginZipPublicationToSnapshotsRepository diff --git a/spi/build.gradle b/spi/build.gradle index 1da8d06e4..5a586bd48 100644 --- a/spi/build.gradle +++ b/spi/build.gradle @@ -3,14 +3,89 @@ * SPDX-License-Identifier: Apache-2.0 */ +plugins { + id 'java-library' + id 'maven-publish' +} + +apply plugin: 'maven-publish' apply plugin: 'java' apply plugin: 'opensearch.java-rest-test' apply plugin: 'org.jetbrains.kotlin.jvm' apply plugin: 'jacoco' apply plugin: 'com.github.johnrengelman.shadow' +apply plugin: 'opensearch.repositories' dependencies { compileOnly "org.opensearch:opensearch:${opensearch_version}" compileOnly "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" compileOnly "org.opensearch:common-utils:${common_utils_version}@jar" -} \ No newline at end of file +} + +shadowJar { + archiveClassifier = null +} + +task sourcesJar(type: Jar) { + archiveClassifier = 'sources' + from sourceSets.main.allJava +} + +task javadocJar(type: Jar) { + archiveClassifier = 'javadoc' + from javadoc.destinationDir +} + +publishing { + repositories { + maven { + name = 'staging' + url = "${rootProject.buildDir}/local-staging-repo" + } + maven { + name = "Snapshots" + url = "https://aws.oss.sonatype.org/content/repositories/snapshots" + credentials { + username "$System.env.SONATYPE_USERNAME" + password "$System.env.SONATYPE_PASSWORD" + } + } + } + publications { + shadow(MavenPublication) { + project.shadow.component(it) + groupId = 'org.opensearch.alerting' + artifactId = 'alerting-spi' + + artifact sourcesJar + artifact javadocJar + + pom { + name = "OpenSearch Alerting spi" + packaging = "jar" + url = "https://github.com/opensearch-project/alerting" + description = "OpenSearch Alerting spi" + scm { + connection = "scm:git@github.com:opensearch-project/alerting.git" + developerConnection = "scm:git@github.com:opensearch-project/alerting.git" + url = "git@github.com:opensearch-project/alerting.git" + } + 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/alerting" + } + } + } + } + } + + gradle.startParameter.setShowStacktrace(ShowStacktrace.ALWAYS) + gradle.startParameter.setLogLevel(LogLevel.DEBUG) +}