Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java Client v4] Fix Gradle config to publish to Maven Central #281

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
}
Loading