Browse Source

Fix auto closing of maven central repo (#1402)

Also remove automatic drop on error.
We are not using it,
and I'm not sure if it's a good idea anyway.
pull/1411/head v1.0.0-beta6-dev464
Alexey Tsvetkov 3 years ago committed by GitHub
parent
commit
9f2d767492
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/MavenCentralProperties.kt
  2. 6
      build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/UploadToSonatypeTask.kt
  3. 12
      build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/utils/Json.kt
  4. 1
      build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/utils/SonatypeApi.kt
  5. 24
      build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/utils/SonatypeRestApiClient.kt
  6. 1
      compose/build.gradle.kts
  7. 2
      compose/settings.gradle.kts

4
build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/MavenCentralProperties.kt

@ -23,10 +23,6 @@ class MavenCentralProperties(private val myProject: Project) {
propertyProvider("maven.central.staging.close.after.upload", defaultValue = "false") propertyProvider("maven.central.staging.close.after.upload", defaultValue = "false")
.map { it.toBoolean() } .map { it.toBoolean() }
val autoDropOnError: Provider<Boolean> =
propertyProvider("maven.central.staging.from.after.error", defaultValue = "false")
.map { it.toBoolean() }
val signArtifacts: Boolean val signArtifacts: Boolean
get() = myProject.findProperty("maven.central.sign") == "true" get() = myProject.findProperty("maven.central.sign") == "true"

6
build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/UploadToSonatypeTask.kt

@ -30,9 +30,6 @@ abstract class UploadToSonatypeTask : DefaultTask() {
@get:Internal @get:Internal
abstract val autoCommitOnSuccess: Property<Boolean> abstract val autoCommitOnSuccess: Property<Boolean>
@get:Internal
abstract val autoDropOnError: Property<Boolean>
@get:Internal @get:Internal
abstract val version: Property<String> abstract val version: Property<String>
@ -72,9 +69,6 @@ abstract class UploadToSonatypeTask : DefaultTask() {
sonatype.closeStagingRepo(stagingRepo) sonatype.closeStagingRepo(stagingRepo)
} }
} catch (e: Exception) { } catch (e: Exception) {
if (autoDropOnError.get()) {
sonatype.dropStagingRepo(stagingRepo)
}
throw e throw e
} }
} }

12
build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/utils/Json.kt

@ -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()
}

1
build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/utils/SonatypeApi.kt

@ -13,7 +13,6 @@ interface SonatypeApi {
fun upload(repo: StagingRepo, module: ModuleToUpload) fun upload(repo: StagingRepo, module: ModuleToUpload)
fun stagingProfiles(): StagingProfiles fun stagingProfiles(): StagingProfiles
fun createStagingRepo(profile: StagingProfile, description: String): StagingRepo fun createStagingRepo(profile: StagingProfile, description: String): StagingRepo
fun dropStagingRepo(repo: StagingRepo)
fun closeStagingRepo(repo: StagingRepo) fun closeStagingRepo(repo: StagingRepo)
} }

24
build-helpers/publishing/src/main/kotlin/org/jetbrains/compose/internal/publishing/utils/SonatypeRestApiClient.kt

@ -76,27 +76,13 @@ class SonatypeRestApiClient(
return StagingRepo(response, profile) return StagingRepo(response, profile)
} }
override fun dropStagingRepo(repo: StagingRepo) {
stagingRepoAction("drop", repo)
}
override fun closeStagingRepo(repo: StagingRepo) { override fun closeStagingRepo(repo: StagingRepo) {
stagingRepoAction("finish", repo) logger.info("Closing repository '${repo.id}'")
} buildRequest("service/local/staging/bulk/close") {
val request = "{\"data\":{\"stagedRepositoryIds\":[\"${repo.id}\"]}}"
private fun stagingRepoAction( post(Xml.serialize(request).toRequestBody(Json.mediaType))
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))
}.execute { responseBody -> }.execute { responseBody ->
logger.info("Finished '$action': $logRepoDescription") logger.info("Finished closing repository '${repo.id}': '${responseBody.string()}'")
logger.info("Response: '${responseBody.string()}'")
} }
} }
} }

1
compose/build.gradle.kts

@ -185,7 +185,6 @@ val reuploadArtifactsToMavenCentral by tasks.registering(UploadToSonatypeTask::c
user.set(mavenCentral.user) user.set(mavenCentral.user)
password.set(mavenCentral.password) password.set(mavenCentral.password)
autoCommitOnSuccess.set(mavenCentral.autoCommitOnSuccess) autoCommitOnSuccess.set(mavenCentral.autoCommitOnSuccess)
autoDropOnError.set(mavenCentral.autoDropOnError)
stagingProfileName.set("org.jetbrains.compose") stagingProfileName.set("org.jetbrains.compose")
} }

2
compose/settings.gradle.kts

@ -6,7 +6,7 @@ pluginManagement {
maven("https://maven.pkg.jetbrains.space/public/p/space/maven") maven("https://maven.pkg.jetbrains.space/public/p/space/maven")
} }
dependencies { dependencies {
classpath("org.jetbrains.compose.internal.build-helpers:publishing:0.0.2") classpath("org.jetbrains.compose.internal.build-helpers:publishing:0.1.0")
} }
} }
} }

Loading…
Cancel
Save