Fix dependencies of release task

This commit is contained in:
Iaroslav Postovalov 2021-07-21 19:01:10 +07:00
parent b751e79a8a
commit 852158c665

View File

@ -27,6 +27,12 @@ class KSciencePublishingExtension(val project: Project) {
} }
} }
private fun linkPublicationsToReleaseTask(name: String) = project.afterEvaluate {
allTasks()
.filter { it.name == "publish${publicationTarget}To${name.capitalize()}Repository" }
.forEach { releaseTask?.dependsOn(it) }
}
/** /**
* github publishing * github publishing
* @param publish include github packages in release publishing. By default - false * @param publish include github packages in release publishing. By default - false
@ -38,15 +44,7 @@ class KSciencePublishingExtension(val project: Project) {
} }
project.addGithubPublishing(githubOrg, githubProject) project.addGithubPublishing(githubOrg, githubProject)
if (publish) linkPublicationsToReleaseTask("github")
if (publish)
project.afterEvaluate {
allTasks()
.find { it.name == "publish${publicationTarget}ToGithubRepository" }
?.let { publicationTask ->
releaseTask?.dependsOn(publicationTask)
}
}
} }
private val releaseTask by lazy { private val releaseTask by lazy {
@ -60,12 +58,7 @@ class KSciencePublishingExtension(val project: Project) {
require(initializedFlag) { "The project vcs is not set up use 'vcs' method to do so" } require(initializedFlag) { "The project vcs is not set up use 'vcs' method to do so" }
project.addSpacePublishing(spaceRepo) project.addSpacePublishing(spaceRepo)
if (publish) if (publish) linkPublicationsToReleaseTask("space")
project.afterEvaluate {
allTasks()
.find { it.name == "publish${publicationTarget}ToSpaceRepository" }
?.let { publicationTask -> releaseTask?.dependsOn(publicationTask) }
}
} }
// // Bintray publishing // // Bintray publishing
@ -81,12 +74,7 @@ class KSciencePublishingExtension(val project: Project) {
require(initializedFlag) { "The project vcs is not set up use 'vcs' method to do so" } require(initializedFlag) { "The project vcs is not set up use 'vcs' method to do so" }
project.addSonatypePublishing() project.addSonatypePublishing()
if (publish) if (publish) linkPublicationsToReleaseTask("sonatype")
project.afterEvaluate {
allTasks()
.find { it.name == "publish${publicationTarget}ToSonatypeRepository" }
?.let { publicationTask -> releaseTask?.dependsOn(publicationTask) }
}
} }
} }