Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db9392a
commit 2c1f3dd
Showing
5 changed files
with
89 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
plugin/src/main/kotlin/com/vanniktech/maven/publish/sonatype/DropSonatypeRepositoryTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.vanniktech.maven.publish.sonatype | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.Internal | ||
import org.gradle.api.tasks.Optional | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.api.tasks.TaskContainer | ||
import org.gradle.api.tasks.TaskProvider | ||
import org.gradle.api.tasks.options.Option | ||
|
||
internal abstract class DropSonatypeRepositoryTask : DefaultTask() { | ||
|
||
@get:Internal | ||
abstract val buildService: Property<SonatypeRepositoryBuildService> | ||
|
||
@Option(option = "repository", description = "Specify which staging repository to drop.") | ||
@Input | ||
@Optional | ||
var manualStagingRepositoryId: String? = null | ||
|
||
@TaskAction | ||
fun closeAndReleaseRepository() { | ||
val service = this.buildService.get() | ||
|
||
// if repository was already dropped in this build this is a no-op | ||
if (service.repositoryDropped) { | ||
return | ||
} | ||
|
||
val manualStagingRepositoryId = this.manualStagingRepositoryId | ||
if (manualStagingRepositoryId != null) { | ||
service.nexus.dropStagingRepository(manualStagingRepositoryId) | ||
} else { | ||
service.nexus.dropCurrentStagingRepository() | ||
} | ||
|
||
service.repositoryDropped = true | ||
} | ||
|
||
companion object { | ||
private const val NAME = "dropRepository" | ||
|
||
fun TaskContainer.registerDropRepository( | ||
buildService: Provider<SonatypeRepositoryBuildService>, | ||
): TaskProvider<DropSonatypeRepositoryTask> { | ||
return register(NAME, DropSonatypeRepositoryTask::class.java) { | ||
it.description = "Drops a staging repository on Sonatype OSS" | ||
it.group = "release" | ||
it.buildService.set(buildService) | ||
it.usesService(buildService) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters