Skip to content

Commit

Permalink
Fix auto closing of maven central repo (#1402)
Browse files Browse the repository at this point in the history
Also remove automatic drop on error.
We are not using it,
and I'm not sure if it's a good idea anyway.
  • Loading branch information
AlexeyTsvetkov authored Nov 15, 2021
1 parent 892670d commit 9f2d767
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ class MavenCentralProperties(private val myProject: Project) {
propertyProvider("maven.central.staging.close.after.upload", defaultValue = "false")
.map { it.toBoolean() }

val autoDropOnError: Provider<Boolean> =
propertyProvider("maven.central.staging.from.after.error", defaultValue = "false")
.map { it.toBoolean() }

val signArtifacts: Boolean
get() = myProject.findProperty("maven.central.sign") == "true"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ abstract class UploadToSonatypeTask : DefaultTask() {
@get:Internal
abstract val autoCommitOnSuccess: Property<Boolean>

@get:Internal
abstract val autoDropOnError: Property<Boolean>

@get:Internal
abstract val version: Property<String>

Expand Down Expand Up @@ -72,9 +69,6 @@ abstract class UploadToSonatypeTask : DefaultTask() {
sonatype.closeStagingRepo(stagingRepo)
}
} catch (e: Exception) {
if (autoDropOnError.get()) {
sonatype.dropStagingRepo(stagingRepo)
}
throw e
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/

package org.jetbrains.compose.internal.publishing.utils

import okhttp3.MediaType.Companion.toMediaType

internal object Json {
val mediaType = "application/json".toMediaType()
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ interface SonatypeApi {
fun upload(repo: StagingRepo, module: ModuleToUpload)
fun stagingProfiles(): StagingProfiles
fun createStagingRepo(profile: StagingProfile, description: String): StagingRepo
fun dropStagingRepo(repo: StagingRepo)
fun closeStagingRepo(repo: StagingRepo)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,13 @@ class SonatypeRestApiClient(
return StagingRepo(response, profile)
}

override fun dropStagingRepo(repo: StagingRepo) {
stagingRepoAction("drop", repo)
}

override fun closeStagingRepo(repo: StagingRepo) {
stagingRepoAction("finish", repo)
}

private fun stagingRepoAction(
action: String, repo: StagingRepo
) {
val logRepoDescription = "profileId='${repo.profile.id}', repoId='${repo.id}', description='${repo.description}'"
logger.info("Starting '$action': $logRepoDescription")
buildRequest("service/local/staging/${repo.profile.id}/$action") {
val promoteRequest = StagingRepo.PromoteRequest(
StagingRepo.PromoteData(stagedRepositoryId = repo.id, description = repo.description)
)
post(Xml.serialize(promoteRequest).toRequestBody(Xml.mediaType))
logger.info("Closing repository '${repo.id}'")
buildRequest("service/local/staging/bulk/close") {
val request = "{\"data\":{\"stagedRepositoryIds\":[\"${repo.id}\"]}}"
post(Xml.serialize(request).toRequestBody(Json.mediaType))
}.execute { responseBody ->
logger.info("Finished '$action': $logRepoDescription")
logger.info("Response: '${responseBody.string()}'")
logger.info("Finished closing repository '${repo.id}': '${responseBody.string()}'")
}
}
}
1 change: 0 additions & 1 deletion compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ val reuploadArtifactsToMavenCentral by tasks.registering(UploadToSonatypeTask::c
user.set(mavenCentral.user)
password.set(mavenCentral.password)
autoCommitOnSuccess.set(mavenCentral.autoCommitOnSuccess)
autoDropOnError.set(mavenCentral.autoDropOnError)
stagingProfileName.set("org.jetbrains.compose")
}

Expand Down
2 changes: 1 addition & 1 deletion compose/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pluginManagement {
maven("https://maven.pkg.jetbrains.space/public/p/space/maven")
}
dependencies {
classpath("org.jetbrains.compose.internal.build-helpers:publishing:0.0.2")
classpath("org.jetbrains.compose.internal.build-helpers:publishing:0.1.0")
}
}
}
Expand Down

0 comments on commit 9f2d767

Please sign in to comment.