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.component1
import kotlin.collections.component2 import kotlin.collections.component2
@Suppress("unused")
class KSciencePublishingExtension(val project: Project) { class KSciencePublishingExtension(val project: Project) {
var vcs: String? by project.extra var vcs: String? by project.extra
@ -126,12 +127,8 @@ open class KScienceProjectPlugin : Plugin<Project> {
appendln("<hr/>") appendln("<hr/>")
} }
val rootReadmeProperties: Map<String, Any?> = mapOf( val rootReadmeProperties: Map<String, Any?> =
"name" to project.name, rootReadmeExtension.properties + ("modules" to modulesString)
"group" to project.group,
"version" to project.version,
"modules" to modulesString
)
readmeFile.writeText( readmeFile.writeText(
SimpleTemplateEngine().createTemplate(rootReadmeExtension.readmeTemplate) SimpleTemplateEngine().createTemplate(rootReadmeExtension.readmeTemplate)

View File

@ -15,16 +15,11 @@ private fun Project.isSnapshot() = version.toString().contains("dev") || version
open class KSciencePublishingPlugin : Plugin<Project> { 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) { if (plugins.findPlugin("maven-publish") == null) {
plugins.apply("maven-publish") 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> { configure<PublishingExtension> {
plugins.withId("org.jetbrains.kotlin.js") { plugins.withId("org.jetbrains.kotlin.js") {
val kotlin = extensions.findByType<KotlinJsProjectExtension>()!! 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) { val dokkaJar: Jar by tasks.creating(Jar::class) {
group = "documentation" group = "documentation"
archiveClassifier.set("javadoc") archiveClassifier.set("javadoc")
@ -206,3 +211,4 @@ open class KSciencePublishingPlugin : Plugin<Project> {
} }
} }
} }
}