diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 3199c5cc..75dc8eb9 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -36,4 +36,9 @@ 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 publishAllPublicationsToSnapshotsRepository + # For JS-SPI jar + ./gradlew publishShadowPublicationToSnapshotsRepository + # For JS jar + ./gradlew publishNebulaPublicationToSnapshotsRepository + # For JS plugin zip + ./gradlew publishPluginZipPublicationToSnapshotsRepository diff --git a/build.gradle b/build.gradle index 5afb6214..b85b83a2 100644 --- a/build.gradle +++ b/build.gradle @@ -52,40 +52,6 @@ forbiddenApisTest.ignoreFailures = true validateNebulaPom.enabled = false loggerUsageCheck.enabled = false -// Order is publish nebula, then jar then zip - -tasks.whenTaskAdded {task -> - if(task.name.contains("validatePluginJarPom") || task.name.contains("validatePluginZipPom")) { - task.enabled = false - } -} - -tasks.matching {it.path in [ - ":generatePomFileForPluginJarPublication" -]}.all { task -> - task.mustRunAfter 'publishNebulaPublicationToMavenLocal', 'publishNebulaPublicationToSnapshotsRepository', 'publishNebulaPublicationToStagingRepository' -} - -tasks.matching {it.path in [ - ":publishPluginJarPublicationToMavenLocal", - ":validatePluginJarPom" -]}.all { task -> - task.dependsOn 'generatePomFileForPluginJarPublication' -} - -tasks.matching {it.path in [ - ":generatePomFileForPluginZipPublication" -]}.all { task -> - task.mustRunAfter 'publishPluginJarPublicationToMavenLocal', 'publishPluginJarPublicationToSnapshotsRepository', 'publishPluginJarPublicationToStagingRepository' -} - -tasks.matching {it.path in [ - ":publishPluginZipPublicationToMavenLocal", - ":validatePluginZipPom" -]}.all { task -> - task.dependsOn 'generatePomFileForPluginZipPublication' -} - opensearchplugin { name 'opensearch-job-scheduler' description 'OpenSearch Job Scheduler plugin' @@ -123,49 +89,47 @@ allprojects { // Default to the apache license project.ext.licenseName = 'The Apache Software License, Version 2.0' project.ext.licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + plugins.withType(ShadowPlugin).whenPluginAdded { + publishing { + repositories { + maven { + name = 'staging' + url = "${rootProject.buildDir}/local-staging-repo" + } + } + publications { + // add license information to generated poms + all { + pom { + name = "opensearch-job-scheduler" + description = "OpenSearch Job Scheduler plugin" + } + pom.withXml { XmlProvider xml -> + Node node = xml.asNode() + node.appendNode('inceptionYear', '2021') + + Node license = node.appendNode('licenses').appendNode('license') + license.appendNode('name', project.licenseName) + license.appendNode('url', project.licenseUrl) + + Node developer = node.appendNode('developers').appendNode('developer') + developer.appendNode('name', 'OpenSearch') + developer.appendNode('url', 'https://github.com/opensearch-project/job-scheduler') + } + } + } + } + } } publishing { publications { - pluginZip(MavenPublication) { + pluginZip(MavenPublication) { publication -> pom { name = "opensearch-job-scheduler" description = "OpenSearch Job Scheduler plugin" - packaging = "zip" groupId = "org.opensearch.plugin" } - pom.withXml { XmlProvider xml -> - Node node = xml.asNode() - node.appendNode('inceptionYear', '2021') - - Node license = node.appendNode('licenses').appendNode('license') - license.appendNode('name', project.licenseName) - license.appendNode('url', project.licenseUrl) - - Node developer = node.appendNode('developers').appendNode('developer') - developer.appendNode('name', 'OpenSearch') - developer.appendNode('url', 'https://github.com/opensearch-project/job-scheduler') - } - } - pluginJar(MavenPublication){ - pom { - name = "opensearch-job-scheduler" - description = "OpenSearch Job Scheduler plugin" - packaging = "jar" - groupId = "org.opensearch" - } - pom.withXml { XmlProvider xml -> - Node node = xml.asNode() - node.appendNode('inceptionYear', '2021') - - Node license = node.appendNode('licenses').appendNode('license') - license.appendNode('name', project.licenseName) - license.appendNode('url', project.licenseUrl) - - Node developer = node.appendNode('developers').appendNode('developer') - developer.appendNode('name', 'OpenSearch') - developer.appendNode('url', 'https://github.com/opensearch-project/job-scheduler') - } } } repositories { @@ -177,10 +141,6 @@ publishing { password "$System.env.SONATYPE_PASSWORD" } } - maven { - name = 'Staging' - url = "${rootProject.buildDir}/local-staging-repo" - } } } diff --git a/settings.gradle b/settings.gradle index 033f4443..89529542 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,3 +10,4 @@ project(":spi").name = rootProject.name + "-spi" include "sample-extension-plugin" project(":sample-extension-plugin").name = rootProject.name + "-sample-extension" +startParameter.excludedTaskNames=["publishPluginZipPublicationToMavenLocal", "publishPluginZipPublicationToStagingRepository"]