Fix plugin resolution
This commit is contained in:
parent
878405ac6a
commit
db9b4dec50
@ -21,8 +21,6 @@ repositories {
|
|||||||
maven("https://repo.kotlin.link")
|
maven("https://repo.kotlin.link")
|
||||||
}
|
}
|
||||||
|
|
||||||
val kotlinVersion = "1.5.30"
|
|
||||||
|
|
||||||
java.targetCompatibility = JavaVersion.VERSION_11
|
java.targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
|
||||||
kotlin.explicitApiWarning()
|
kotlin.explicitApiWarning()
|
||||||
@ -35,6 +33,13 @@ dependencies {
|
|||||||
implementation(libs.dokka.gradle)
|
implementation(libs.dokka.gradle)
|
||||||
implementation(libs.kotlin.jupyter.gradle)
|
implementation(libs.kotlin.jupyter.gradle)
|
||||||
implementation(libs.kotlin.serialization)
|
implementation(libs.kotlin.serialization)
|
||||||
|
implementation("org.tomlj:tomlj:1.0.0")
|
||||||
|
|
||||||
|
testImplementation(kotlin("test"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.test {
|
||||||
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
//declaring exported plugins
|
//declaring exported plugins
|
||||||
@ -203,5 +208,6 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.processResources.configure {
|
tasks.processResources.configure {
|
||||||
|
duplicatesStrategy = org.gradle.api.file.DuplicatesStrategy.INCLUDE
|
||||||
from("gradle/libs.versions.toml")
|
from("gradle/libs.versions.toml")
|
||||||
}
|
}
|
@ -82,7 +82,7 @@ public class KScienceExtension(public val project: Project) {
|
|||||||
configuration: DependencyConfiguration = DependencyConfiguration.API,
|
configuration: DependencyConfiguration = DependencyConfiguration.API,
|
||||||
block: SerializationTargets.() -> Unit = {},
|
block: SerializationTargets.() -> Unit = {},
|
||||||
): Unit = project.run {
|
): Unit = project.run {
|
||||||
apply("org.jetbrains.kotlin.plugin.serialization")
|
plugins.apply("org.jetbrains.kotlin.plugin.serialization")
|
||||||
val artifactName = if (version.startsWith("0")) {
|
val artifactName = if (version.startsWith("0")) {
|
||||||
"kotlinx-serialization-runtime"
|
"kotlinx-serialization-runtime"
|
||||||
} else {
|
} else {
|
||||||
@ -137,14 +137,14 @@ public class KScienceExtension(public val project: Project) {
|
|||||||
*/
|
*/
|
||||||
@Deprecated("Use jupyterLibrary")
|
@Deprecated("Use jupyterLibrary")
|
||||||
public fun useJupyter() {
|
public fun useJupyter() {
|
||||||
project.apply("org.jetbrains.kotlin.jupyter.api")
|
project.plugins.apply("org.jetbrains.kotlin.jupyter.api")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply jupyter plugin and add entry point for the jupyter library
|
* Apply jupyter plugin and add entry point for the jupyter library
|
||||||
*/
|
*/
|
||||||
public fun jupyterLibrary(pluginClass: String, vararg additionalPluginClasses: String) {
|
public fun jupyterLibrary(pluginClass: String, vararg additionalPluginClasses: String) {
|
||||||
project.apply("org.jetbrains.kotlin.jupyter.api")
|
project.plugins.apply("org.jetbrains.kotlin.jupyter.api")
|
||||||
project.tasks.named("processJupyterApiResources", JupyterApiResourcesTask::class.java) {
|
project.tasks.named("processJupyterApiResources", JupyterApiResourcesTask::class.java) {
|
||||||
libraryProducers = listOf(pluginClass, *additionalPluginClasses)
|
libraryProducers = listOf(pluginClass, *additionalPluginClasses)
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import org.gradle.kotlin.dsl.apply
|
|||||||
public open class KScienceJSPlugin : Plugin<Project> {
|
public open class KScienceJSPlugin : Plugin<Project> {
|
||||||
override fun apply(project: Project): Unit = project.run {
|
override fun apply(project: Project): Unit = project.run {
|
||||||
if (!plugins.hasPlugin("org.jetbrains.kotlin.js")) {
|
if (!plugins.hasPlugin("org.jetbrains.kotlin.js")) {
|
||||||
apply("org.jetbrains.kotlin.js")
|
plugins.apply("org.jetbrains.kotlin.js")
|
||||||
} else {
|
} else {
|
||||||
logger.info("Kotlin JS plugin is already present")
|
logger.info("Kotlin JS plugin is already present")
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import org.gradle.kotlin.dsl.apply
|
|||||||
public open class KScienceJVMPlugin : Plugin<Project> {
|
public open class KScienceJVMPlugin : Plugin<Project> {
|
||||||
override fun apply(project: Project): Unit = project.run {
|
override fun apply(project: Project): Unit = project.run {
|
||||||
if (!plugins.hasPlugin("org.jetbrains.kotlin.jvm"))
|
if (!plugins.hasPlugin("org.jetbrains.kotlin.jvm"))
|
||||||
apply("org.jetbrains.kotlin.jvm")
|
plugins.apply("org.jetbrains.kotlin.jvm")
|
||||||
else
|
else
|
||||||
logger.info("Kotlin JVM plugin is already present")
|
logger.info("Kotlin JVM plugin is already present")
|
||||||
|
|
||||||
|
@ -3,11 +3,13 @@ package ru.mipt.npm.gradle
|
|||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.apply
|
import org.gradle.kotlin.dsl.apply
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
|
||||||
|
|
||||||
public open class KScienceMPPlugin : Plugin<Project> {
|
public open class KScienceMPPlugin : Plugin<Project> {
|
||||||
override fun apply(project: Project): Unit = project.run {
|
override fun apply(project: Project): Unit = project.run {
|
||||||
if (!plugins.hasPlugin("org.jetbrains.kotlin.multiplatform")) {
|
if (!plugins.hasPlugin(KotlinMultiplatformPlugin::class)) {
|
||||||
apply("org.jetbrains.kotlin.multiplatform")
|
//apply<KotlinMultiplatformPlugin>() for some reason it does not work
|
||||||
|
plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||||
} else {
|
} else {
|
||||||
logger.info("Kotlin MPP plugin is already present")
|
logger.info("Kotlin MPP plugin is already present")
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ public class KScienceNativePlugin : Plugin<Project> {
|
|||||||
//Apply multiplatform plugin is not applied, apply it
|
//Apply multiplatform plugin is not applied, apply it
|
||||||
if (!plugins.hasPlugin("org.jetbrains.kotlin.multiplatform")) {
|
if (!plugins.hasPlugin("org.jetbrains.kotlin.multiplatform")) {
|
||||||
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
|
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
|
||||||
apply("org.jetbrains.kotlin.multiplatform")
|
plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugins.hasPlugin(KScienceCommonPlugin::class)) {
|
if (!plugins.hasPlugin(KScienceCommonPlugin::class)) {
|
||||||
|
@ -2,10 +2,7 @@ package ru.mipt.npm.gradle
|
|||||||
|
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.apply
|
import org.gradle.kotlin.dsl.*
|
||||||
import org.gradle.kotlin.dsl.configure
|
|
||||||
import org.gradle.kotlin.dsl.findPlugin
|
|
||||||
import org.gradle.kotlin.dsl.invoke
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,7 +13,7 @@ public class KScienceNodePlugin : Plugin<Project> {
|
|||||||
//Apply multiplatform plugin is not applied, apply it
|
//Apply multiplatform plugin is not applied, apply it
|
||||||
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
|
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
|
||||||
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
|
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
|
||||||
apply("org.jetbrains.kotlin.multiplatform")
|
plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
|
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
|
||||||
|
@ -1,31 +1,32 @@
|
|||||||
package ru.mipt.npm.gradle
|
package ru.mipt.npm.gradle
|
||||||
|
|
||||||
|
|
||||||
import org.gradle.api.JavaVersion
|
import org.gradle.api.JavaVersion
|
||||||
import org.gradle.internal.impldep.org.tomlj.Toml
|
import org.tomlj.Toml
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build constants
|
* Build constants
|
||||||
*/
|
*/
|
||||||
public object KScienceVersions {
|
public object KScienceVersions {
|
||||||
|
|
||||||
private val toml =
|
private val toml by lazy {
|
||||||
Toml.parse(KScienceVersions.javaClass.getResource("/libs.versions.toml")!!.readText())
|
Toml.parse(javaClass.getResource("/libs.versions.toml")!!.readText())
|
||||||
|
}
|
||||||
|
|
||||||
|
public val kotlinVersion: String get() = toml.getString("versions.kotlin")!!
|
||||||
public val kotlinVersion: String = toml.getString("versions.kotlin")!!
|
public val kotlinxNodeVersion: String get() = toml.getString("versions.kotlinx-nodejs")!!
|
||||||
public val kotlinxNodeVersion: String = toml.getString("versions.kotlinx-nodejs")!!
|
public val coroutinesVersion: String get() = toml.getString("versions.kotlinx-coroutines")!!
|
||||||
public val coroutinesVersion: String = toml.getString("versions.kotlinx-coroutines")!!
|
public val serializationVersion: String get() = toml.getString("versions.kotlinx-serialization")!!
|
||||||
public val serializationVersion: String = toml.getString("versions.kotlinx-serialization")!!
|
public val atomicVersion: String get() = toml.getString("versions.atomicfu")!!
|
||||||
public val atomicVersion: String = toml.getString("versions.atomicfu")!!
|
public val ktorVersion: String get() = toml.getString("versions.ktor")!!
|
||||||
public val ktorVersion: String = toml.getString("versions.ktor")!!
|
public val htmlVersion: String get() = toml.getString("versions.kotlinx-html")!!
|
||||||
public val htmlVersion: String = toml.getString("versions.kotlinx-html")!!
|
public val dateTimeVersion: String get() = toml.getString("versions.kotlinx-datetime")!!
|
||||||
public val dateTimeVersion: String = toml.getString("versions.kotlinx-datetime")!!
|
public val jsBom: String get() = toml.getString("versions.jsBom")!!
|
||||||
public val jsBom: String = toml.getString("versions.jsBom")!!
|
|
||||||
|
|
||||||
public val JVM_TARGET: JavaVersion = JavaVersion.VERSION_11
|
public val JVM_TARGET: JavaVersion = JavaVersion.VERSION_11
|
||||||
|
|
||||||
public object Serialization {
|
public object Serialization {
|
||||||
public val xmlVersion: String = toml.getString("versions.xmlutil")!!
|
public val xmlVersion: String get() = toml.getString("versions.xmlutil")!!
|
||||||
public val yamlKtVersion: String = toml.getString("versions.yamlkt")!!
|
public val yamlKtVersion: String get() = toml.getString("versions.yamlkt")!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
src/test/kotlin/TestVersions.kt
Normal file
10
src/test/kotlin/TestVersions.kt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package ru.mipt.npm.gradle
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
class TestPlugins {
|
||||||
|
@Test
|
||||||
|
fun testVersions() {
|
||||||
|
println(KScienceVersions.coroutinesVersion)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user