Skip to content

Commit

Permalink
[#4] Simplify NexusStagingRepository class
Browse files Browse the repository at this point in the history
  • Loading branch information
szpak committed Jan 3, 2020
1 parent 716a6b1 commit a22e537
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ constructor(objects: ObjectFactory, extension: NexusPublishExtension, repository
}

protected fun keepStagingRepositoryIdInExtension(stagingRepositoryIdAsString: String) {
repository.get().stagingRepository.set(NexusStagingRepository(stagingRepositoryIdAsString, project))
repository.get().stagingRepository.set(NexusStagingRepository(stagingRepositoryIdAsString))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package io.github.gradlenexus.publishplugin
import io.github.gradlenexus.publishplugin.internal.NexusClient
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Nested
import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.property
Expand All @@ -30,7 +29,6 @@ open class CloseNexusStagingRepository @Inject
constructor(objects: ObjectFactory, extension: NexusPublishExtension, repository: NexusRepository) :
AbstractNexusStagingRepositoryTask(objects, extension, repository) {

@get:Input
@get:Nested
val stagingRepository: Property<NexusStagingRepository> = objects.property()

Expand All @@ -45,8 +43,8 @@ constructor(objects: ObjectFactory, extension: NexusPublishExtension, repository
fun closeStagingRepo() {
val client = NexusClient(repository.get().nexusUrl.get(), repository.get().username.orNull, repository.get().password.orNull, clientTimeout.orNull, connectTimeout.orNull)
val stagingProfileId = determineStagingProfileId(client)
logger.info("Closing staging repository with id '{}' for stagingProfileId '{}'", stagingRepository.get().stagingRepositoryId.get(), stagingProfileId)
client.closeStagingRepository(stagingRepository.get().stagingRepositoryId.get())
logger.info("Closing staging repository with id '{}' for stagingProfileId '{}'", stagingRepository.get().id, stagingProfileId)
client.closeStagingRepository(stagingRepository.get().id)
// TODO: Broken with real Nexus - waiting for effective execution is also required https://github.com/gradle-nexus/publish-plugin/issues/7
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@

package io.github.gradlenexus.publishplugin

import org.gradle.api.Project
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Internal
import org.gradle.kotlin.dsl.property
import javax.inject.Inject
import org.gradle.api.tasks.Input

@Suppress("UnstableApiUsage")
open class NexusStagingRepository @Inject constructor(stagingRepositoryIdAsString: String, project: Project) {

@Internal
val stagingRepositoryId: Property<String> = project.objects.property()

init {
stagingRepositoryId.set(stagingRepositoryIdAsString)
}
}
open class NexusStagingRepository constructor(@get:Input val id: String)
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package io.github.gradlenexus.publishplugin
import io.github.gradlenexus.publishplugin.internal.NexusClient
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Nested
import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.property
Expand All @@ -31,7 +30,6 @@ open class ReleaseNexusStagingRepository @Inject
constructor(objects: ObjectFactory, extension: NexusPublishExtension, repository: NexusRepository) :
AbstractNexusStagingRepositoryTask(objects, extension, repository) {

@get:Input
@get:Nested
val stagingRepository: Property<NexusStagingRepository> = objects.property()

Expand All @@ -46,8 +44,8 @@ constructor(objects: ObjectFactory, extension: NexusPublishExtension, repository
fun releaseStagingRepo() {
val client = NexusClient(repository.get().nexusUrl.get(), repository.get().username.orNull, repository.get().password.orNull, clientTimeout.orNull, connectTimeout.orNull)
val stagingProfileId = determineStagingProfileId(client) // TODO: Will it update value in extension?
logger.info("Releasing staging repository with id '{}' for stagingProfileId '{}'", stagingRepository.get().stagingRepositoryId.get(), stagingProfileId)
client.releaseStagingRepository(stagingRepository.get().stagingRepositoryId.get())
logger.info("Releasing staging repository with id '{}' for stagingProfileId '{}'", stagingRepository.get().id, stagingProfileId)
client.releaseStagingRepository(stagingRepository.get().id)
// TODO: Broken with real Nexus - waiting for effective execution is also required https://github.com/gradle-nexus/publish-plugin/issues/7
}
}

0 comments on commit a22e537

Please sign in to comment.