diff --git a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt index bdb3661..21617ad 100644 --- a/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt +++ b/sonatype/src/main/kotlin/com/bakdata/gradle/SonatypePlugin.kt @@ -80,6 +80,10 @@ class SonatypePlugin : Plugin { addParentPublishToNexusTasks() disallowPublishTasks() + + tasks.named("closeRepository") { + mustRunAfter("publishToNexus") + } } } @@ -91,12 +95,7 @@ class SonatypePlugin : Plugin { val parent = project.parent if (parent != null) { tasks.matching { it.name == "publishToNexus" }.configureEach { - val parentProvider = - try { - parent.tasks.named("publishToNexus") - } catch (e: UnknownTaskException) { - parent.tasks.register("publishToNexus") - } + val parentProvider = parent.tasks.named("publishToNexus") this.let { childTask -> parentProvider.configure { dependsOn(childTask)