Fix plugin loading order for publishing

This commit is contained in:
Alexander Nozik 2021-02-23 13:22:41 +03:00
parent 9c12501a57
commit 133736f00f
3 changed files with 192 additions and 176 deletions

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -20,11 +20,6 @@ open class KScienceCommonPlugin : Plugin<Project> {
registerKScienceExtension()
repositories.applyRepos()
// apply dokka for all projects
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
plugins.apply("org.jetbrains.dokka")
}
//Configuration for K-JVM plugin
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
//logger.info("Applying KScience configuration for JVM project")
@ -43,6 +38,22 @@ open class KScienceCommonPlugin : Plugin<Project> {
}
}
}
tasks.withType<KotlinJvmCompile> {
kotlinOptions {
useIR = true
jvmTarget = KScienceVersions.JVM_TARGET.toString()
}
}
extensions.findByType<JavaPluginExtension>()?.apply {
targetCompatibility = KScienceVersions.JVM_TARGET
}
tasks.apply {
withType<Test> {
useJUnitPlatform()
}
}
}
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
@ -123,25 +134,23 @@ open class KScienceCommonPlugin : Plugin<Project> {
(tasks.findByName("jsProcessResources") as? Copy)?.apply {
fromJsDependencies("jsRuntimeClasspath")
}
}
}
afterEvaluate {
extensions.findByType<JavaPluginExtension>()?.apply {
targetCompatibility = KScienceVersions.JVM_TARGET
}
tasks.apply {
withType<KotlinJvmCompile> {
kotlinOptions {
useIR = true
jvmTarget = KScienceVersions.JVM_TARGET.toString()
}
}
withType<Test> {
useJUnitPlatform()
}
}
}
}
// apply dokka for all projects
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
plugins.apply("org.jetbrains.dokka")
}
}
}

View File

@ -15,7 +15,10 @@ private fun Project.isSnapshot() = version.toString().contains("dev") || version
open class KSciencePublishingPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
override fun apply(project: Project): Unit {
//Add publishing plugin and new publications
project.run {
if (plugins.findPlugin("maven-publish") == null) {
plugins.apply("maven-publish")
}
@ -53,8 +56,11 @@ open class KSciencePublishingPlugin : Plugin<Project> {
}
}
}
}
project.afterEvaluate {
//configure publications after everything is set in the root project
project.rootProject.afterEvaluate {
project.run {
val githubOrg: String = project.findProperty("githubOrg") as? String ?: "mipt-npm"
val githubProject: String? by project
val vcs = findProperty("vcs") as? String
@ -210,6 +216,7 @@ open class KSciencePublishingPlugin : Plugin<Project> {
}
}
}
}
}