Move maven-publish to configuration phase

This commit is contained in:
Alexander Nozik 2021-02-22 20:35:12 +03:00
parent a7f4c541f4
commit 4c656a3f61
2 changed files with 163 additions and 160 deletions

View File

@ -11,6 +11,7 @@ import org.jetbrains.dokka.gradle.DokkaTask
import kotlin.collections.component1
import kotlin.collections.component2
@Suppress("unused")
class KSciencePublishingExtension(val project: Project) {
var vcs: String? by project.extra
@ -126,12 +127,8 @@ open class KScienceProjectPlugin : Plugin<Project> {
appendln("<hr/>")
}
val rootReadmeProperties: Map<String, Any?> = mapOf(
"name" to project.name,
"group" to project.group,
"version" to project.version,
"modules" to modulesString
)
val rootReadmeProperties: Map<String, Any?> =
rootReadmeExtension.properties + ("modules" to modulesString)
readmeFile.writeText(
SimpleTemplateEngine().createTemplate(rootReadmeExtension.readmeTemplate)
@ -155,7 +152,7 @@ open class KScienceProjectPlugin : Plugin<Project> {
dependsOn(generateReadme)
val publicationPlatform = project.findProperty("ci.publication.platform") as? String
val publicationName = if(publicationPlatform == null){
val publicationName = if (publicationPlatform == null) {
"AllPublications"
} else {
publicationPlatform.capitalize() + "Publication"

View File

@ -15,16 +15,11 @@ private fun Project.isSnapshot() = version.toString().contains("dev") || version
open class KSciencePublishingPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.afterEvaluate {
override fun apply(project: Project): Unit {
project.run {
if (plugins.findPlugin("maven-publish") == null) {
plugins.apply("maven-publish")
}
val githubOrg: String = project.findProperty("githubOrg") as? String ?: "mipt-npm"
val githubProject: String? by project
val vcs = findProperty("vcs") as? String
?: githubProject?.let { "https://github.com/$githubOrg/$it" }
configure<PublishingExtension> {
plugins.withId("org.jetbrains.kotlin.js") {
val kotlin = extensions.findByType<KotlinJsProjectExtension>()!!
@ -57,7 +52,17 @@ open class KSciencePublishingPlugin : Plugin<Project> {
}
}
}
}
}
project.afterEvaluate {
val githubOrg: String = project.findProperty("githubOrg") as? String ?: "mipt-npm"
val githubProject: String? by project
val vcs = findProperty("vcs") as? String
?: githubProject?.let { "https://github.com/$githubOrg/$it" }
configure<PublishingExtension> {
val dokkaJar: Jar by tasks.creating(Jar::class) {
group = "documentation"
archiveClassifier.set("javadoc")
@ -205,4 +210,5 @@ open class KSciencePublishingPlugin : Plugin<Project> {
}
}
}
}
}