Skip to content

Commit

Permalink
Fix the Maven publish
Browse files Browse the repository at this point in the history
Signed-off-by: Prudhvi Godithi <[email protected]>
  • Loading branch information
prudhvigodithi committed May 6, 2023
1 parent db8edff commit ed82135
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 73 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
104 changes: 32 additions & 72 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 {
Expand All @@ -177,10 +141,6 @@ publishing {
password "$System.env.SONATYPE_PASSWORD"
}
}
maven {
name = 'Staging'
url = "${rootProject.buildDir}/local-staging-repo"
}
}
}

Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit ed82135

Please sign in to comment.