Skip to content

Commit

Permalink
Merge pull request #281 from conductor-oss/fix/client-v4-gradle-confi…
Browse files Browse the repository at this point in the history
…g-maven-publish

[Java Client v4] Fix Gradle config to publish to Maven Central
  • Loading branch information
jmigueprieto authored Oct 9, 2024
2 parents 0f23965 + 2ab599a commit a28e0e9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.orkes.conductor.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.plugins.signing.SigningPlugin
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.authentication.aws.AwsImAuthentication

Expand All @@ -11,18 +12,35 @@ class PublishConfigPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.plugins.withType(MavenPublishPlugin) {
config(project)
publishingConfig(project)
}
project.plugins.withType(SigningPlugin) {
signingConfig(project)
}
}

private void config(Project project) {
def publishingConfig(Project project) {
project.publishing {
publications(publicationConfig(project))
repositories(repositoriesConfig(project))
}
}

private publicationConfig(Project project) {
def signingConfig(Project project) {
project.signing {
def signingKeyId = project.findProperty('signingKeyId')
if (signingKeyId) {
def signingKey = project.findProperty('signingKey')
def signingPassword = project.findProperty('signingPassword')
if (signingKeyId && signingKey && signingPassword) {
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
}
sign project.publishing.publications
}
}
}

def publicationConfig(Project project) {
return {
mavenJava(MavenPublication) {
if (project.hasProperty('artifactId')) {
Expand Down Expand Up @@ -58,7 +76,7 @@ class PublishConfigPlugin implements Plugin<Project> {
}
}

private repositoriesConfig(Project project) {
def repositoriesConfig(Project project) {
return {
maven {
if (project.hasProperty("mavenCentral")) {
Expand All @@ -77,11 +95,11 @@ class PublishConfigPlugin implements Plugin<Project> {
}
}

private static String getS3BucketUrl(Project project) {
static String getS3BucketUrl(Project project) {
return "s3://orkes-artifacts-repo/${project.version.endsWith('-SNAPSHOT') ? 'snapshots' : 'releases'}"
}

private static String getMavenRepoUrl(Project project) {
static String getMavenRepoUrl(Project project) {
return "https://s01.oss.sonatype.org/${project.version.endsWith('-SNAPSHOT') ? 'content/repositories/snapshots/' : 'service/local/staging/deploy/maven2/'}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter:3.3.0'
}

java {
withSourcesJar()
withJavadocJar()
}

test {
useJUnitPlatform()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter:3.3.0'
}

java {
withSourcesJar()
withJavadocJar()
}

test {
useJUnitPlatform()
}
}

0 comments on commit a28e0e9

Please sign in to comment.