Fix dependencies of release task #19
@ -5,6 +5,7 @@ import kotlinx.validation.ApiValidationExtension
|
|||||||
import kotlinx.validation.BinaryCompatibilityValidatorPlugin
|
import kotlinx.validation.BinaryCompatibilityValidatorPlugin
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.Task
|
||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
import org.jetbrains.changelog.ChangelogPlugin
|
import org.jetbrains.changelog.ChangelogPlugin
|
||||||
import org.jetbrains.changelog.ChangelogPluginExtension
|
import org.jetbrains.changelog.ChangelogPluginExtension
|
||||||
@ -13,6 +14,8 @@ import org.jetbrains.dokka.gradle.DokkaPlugin
|
|||||||
import org.jetbrains.dokka.gradle.DokkaTask
|
import org.jetbrains.dokka.gradle.DokkaTask
|
||||||
import ru.mipt.npm.gradle.internal.*
|
import ru.mipt.npm.gradle.internal.*
|
||||||
|
|
||||||
|
private fun Project.allTasks(): Set<Task> = allprojects.flatMapTo(HashSet()) { it.tasks }
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
class KSciencePublishingExtension(val project: Project) {
|
class KSciencePublishingExtension(val project: Project) {
|
||||||
private var initializedFlag = false
|
private var initializedFlag = false
|
||||||
@ -33,10 +36,14 @@ class KSciencePublishingExtension(val project: Project) {
|
|||||||
if (!initializedFlag) {
|
if (!initializedFlag) {
|
||||||
vcs("https://github.com/$githubOrg/$githubProject")
|
vcs("https://github.com/$githubOrg/$githubProject")
|
||||||
}
|
}
|
||||||
|
|
||||||
project.addGithubPublishing(githubOrg, githubProject)
|
project.addGithubPublishing(githubOrg, githubProject)
|
||||||
|
|
||||||
if (publish) {
|
if (publish)
|
||||||
project.tasks.findByName("publish${project.publicationTarget}ToGithubRepository")?.let {publicationTask->
|
project.afterEvaluate {
|
||||||
|
allTasks()
|
||||||
|
.find { it.name == "publish${publicationTarget}ToGithubRepository" }
|
||||||
|
?.let { publicationTask ->
|
||||||
releaseTask?.dependsOn(publicationTask)
|
releaseTask?.dependsOn(publicationTask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,10 +59,12 @@ class KSciencePublishingExtension(val project: Project) {
|
|||||||
fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven", publish: Boolean = false) {
|
fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven", publish: Boolean = false) {
|
||||||
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) {
|
|
||||||
project.tasks.findByName("publish${project.publicationTarget}ToSpaceRepository")?.let { publicationTask ->
|
if (publish)
|
||||||
releaseTask?.dependsOn(publicationTask)
|
project.afterEvaluate {
|
||||||
}
|
allTasks()
|
||||||
|
.find { it.name == "publish${publicationTarget}ToSpaceRepository" }
|
||||||
|
?.let { publicationTask -> releaseTask?.dependsOn(publicationTask) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,16 +80,16 @@ class KSciencePublishingExtension(val project: Project) {
|
|||||||
fun sonatype(publish: Boolean = true) {
|
fun sonatype(publish: Boolean = true) {
|
||||||
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) {
|
|
||||||
project.tasks.findByName("publish${project.publicationTarget}ToSonatypeRepository")
|
if (publish)
|
||||||
?.let { publicationTask ->
|
project.afterEvaluate {
|
||||||
releaseTask?.dependsOn(publicationTask)
|
allTasks()
|
||||||
}
|
.find { it.name == "publish${publicationTarget}ToSonatypeRepository" }
|
||||||
|
?.let { publicationTask -> releaseTask?.dependsOn(publicationTask) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply extension and repositories
|
* Apply extension and repositories
|
||||||
*/
|
*/
|
||||||
@ -98,7 +107,7 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
configure<ChangelogPluginExtension> {
|
configure<ChangelogPluginExtension> {
|
||||||
setVersion(project.version.toString())
|
version.set(project.version.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user