a9cd7750f4
CI / detect-changes (push) Waiting to run
CI / build (push) Waiting to run
UI v2 CI / E2E (Mocked) (push) Blocked by required conditions
UI v2 Integration CI / E2E (Integration) (push) Waiting to run
CI / unit-test (push) Blocked by required conditions
CI / test-harness (push) Waiting to run
CI / generate-e2e-matrix (push) Waiting to run
CI / e2e (push) Blocked by required conditions
CI / build-ui (push) Waiting to run
Publish docs via GitHub Pages / Deploy docs (push) Waiting to run
Release Drafter / update_release_draft (push) Waiting to run
UI v2 CI / Lint, Format & Test (push) Waiting to run
131 lines
5.1 KiB
Groovy
131 lines
5.1 KiB
Groovy
subprojects {
|
|
|
|
apply plugin: 'maven-publish'
|
|
apply plugin: 'java-library'
|
|
apply plugin: 'signing'
|
|
|
|
group = 'org.conductoross'
|
|
|
|
java {
|
|
withSourcesJar()
|
|
withJavadocJar()
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
mavenJava(MavenPublication) {
|
|
from components.java
|
|
versionMapping {
|
|
usage('java-api') {
|
|
fromResolutionOf('runtimeClasspath')
|
|
}
|
|
usage('java-runtime') {
|
|
fromResolutionResult()
|
|
}
|
|
}
|
|
pom {
|
|
name = 'Conductor OSS'
|
|
description = 'Conductor OSS build.'
|
|
url = 'https://github.com/conductor-oss/conductor'
|
|
scm {
|
|
connection = 'scm:git:git://github.com/conductor-oss/conductor.git'
|
|
developerConnection = 'scm:git:ssh://github.com/conductor-oss/conductor.git'
|
|
url = 'https://github.com/conductor-oss/conductor'
|
|
}
|
|
licenses {
|
|
license {
|
|
name = 'The Apache License, Version 2.0'
|
|
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
|
}
|
|
}
|
|
developers {
|
|
developer {
|
|
organization = 'Conductor OSS'
|
|
organizationUrl = 'https://conductor-oss.org/'
|
|
name = 'Conductor OSS'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
maven {
|
|
url = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
|
|
credentials {
|
|
username project.properties.username
|
|
password project.properties.password
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
signing {
|
|
def signingKeyId = findProperty('signingKeyId')
|
|
if (signingKeyId) {
|
|
def signingKey = findProperty('signingKey')
|
|
def signingPassword = findProperty('signingPassword')
|
|
if (signingKeyId && signingKey && signingPassword) {
|
|
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
|
|
}
|
|
sign publishing.publications
|
|
}
|
|
|
|
}
|
|
|
|
task promoteToMavenCentral {
|
|
group = 'publishing'
|
|
description = 'Promotes staged artifacts to Maven Central'
|
|
|
|
onlyIf {
|
|
project.hasProperty('mavenCentral') &&
|
|
project.hasProperty('username') &&
|
|
project.hasProperty('password') &&
|
|
!project.version.endsWith('-SNAPSHOT')
|
|
}
|
|
|
|
doLast {
|
|
def username = project.properties['username']
|
|
def password = project.properties['password']
|
|
|
|
// Create base64 encoded token for authentication
|
|
def token = "${username}:${password}".bytes.encodeBase64().toString()
|
|
|
|
// Get open staging repositories
|
|
def response = new URL("https://ossrh-staging-api.central.sonatype.com/manual/search/repositories")
|
|
.openConnection()
|
|
response.setRequestProperty("Authorization", "Basic ${token}")
|
|
response.setRequestProperty("Content-Type", "application/json")
|
|
|
|
def repositories = new groovy.json.JsonSlurper().parse(response.inputStream)
|
|
|
|
// Promote each open repository
|
|
repositories.repositories.each { repo ->
|
|
if (repo.state == "open") {
|
|
project.logger.lifecycle("Promoting repository ${repo.key}")
|
|
|
|
def promoteUrl = new URL("https://ossrh-staging-api.central.sonatype.com/manual/upload/repository/${repo.key}?publishing_type=automatic")
|
|
def connection = promoteUrl.openConnection()
|
|
connection.setRequestMethod("POST")
|
|
connection.setRequestProperty("Authorization", "Basic ${token}")
|
|
connection.setRequestProperty("Content-Type", "application/json")
|
|
|
|
def responseCode = connection.responseCode
|
|
if (responseCode == 200) {
|
|
project.logger.lifecycle("Successfully promoted repository ${repo.key}")
|
|
} else {
|
|
def errorStream = connection.errorStream
|
|
def errorBody = errorStream ? errorStream.text : "No error body available"
|
|
def errorMessage = "Failed to promote repository ${repo.key}. Response code: ${responseCode}. Response message: ${connection.responseMessage}. Error body: ${errorBody}"
|
|
project.logger.error(errorMessage)
|
|
//throw new GradleException(errorMessage)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
tasks.matching { it.name == 'publish' }.configureEach { publishTask ->
|
|
publishTask.finalizedBy tasks.promoteToMavenCentral
|
|
}
|
|
|
|
} |