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

fix: do not fail on closure of already closed Nexus repositories #477

Merged
merged 3 commits into from
Feb 5, 2023
Merged
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
@@ -1,5 +1,6 @@
package org.danilopianini.gradle.mavencentral

import io.github.gradlenexus.publishplugin.internal.StagingRepository
import org.danilopianini.gradle.mavencentral.ProjectExtensions.registerTaskIfNeeded
import org.gradle.api.DefaultTask
import org.gradle.api.Project
Expand Down Expand Up @@ -123,7 +124,15 @@ private fun Project.configureNexusRepository(repoToConfigure: Repository, nexusU
val closeStagingRepository = rootProject.registerTaskIfNeeded<DefaultTask>(
"closeStagingRepositoryOn${repoToConfigure.name}"
) {
doLast { nexusClient.nexusClient.close() }
doLast {
with(nexusClient.nexusClient) {
when (client.getStagingRepositoryStateById(repoId).state) {
StagingRepository.State.CLOSED ->
logger.warn("The staging repository is already closed. Skipping.")
else -> close()
}
}
}
dependsOn(createStagingRepository)
mustRunAfter(uploadAllPublications)
group = PublishingPlugin.PUBLISH_TASK_GROUP
Expand Down