remove Js plugin and deprecated JVM

This commit is contained in:
Alexander Nozik 2023-09-13 12:12:46 +03:00
parent 4f41d90308
commit b27624bf1c
7 changed files with 47 additions and 120 deletions

View File

@ -15,8 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- All publishing targets are enabled by default. Introduce `publishing.targets` variable to regulate what is added to the module. - All publishing targets are enabled by default. Introduce `publishing.targets` variable to regulate what is added to the module.
### Deprecated ### Deprecated
- JVM plugin in favor of Mpp.
### Removed ### Removed
- JS plugin. It is deprecated in favor of MPP.
- Unnecessary `dependsOn` for native dependencies. - Unnecessary `dependsOn` for native dependencies.
- Groovy gradle dependency notation. - Groovy gradle dependency notation.

View File

@ -65,12 +65,6 @@ gradlePlugin {
description = "Pre-configured JVM project" description = "Pre-configured JVM project"
implementationClass = "space.kscience.gradle.KScienceJVMPlugin" implementationClass = "space.kscience.gradle.KScienceJVMPlugin"
} }
create("js") {
id = "space.kscience.gradle.js"
description = "Pre-configured JS project"
implementationClass = "space.kscience.gradle.KScienceJSPlugin"
}
} }
} }

View File

@ -373,8 +373,8 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
project.configure<KotlinMultiplatformExtension> { project.configure<KotlinMultiplatformExtension> {
jvm { jvm {
compilations.all { compilations.all {
kotlinOptions { compilerOptions {
freeCompilerArgs = freeCompilerArgs + defaultKotlinJvmArgs freeCompilerArgs.addAll(defaultKotlinJvmArgs)
} }
} }
block() block()

View File

@ -1,56 +0,0 @@
package space.kscience.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.Copy
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.get
import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
import space.kscience.gradle.internal.applySettings
import space.kscience.gradle.internal.fromJsDependencies
public open class KScienceJSPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
if (!plugins.hasPlugin("org.jetbrains.kotlin.js")) {
plugins.apply("org.jetbrains.kotlin.js")
} else {
logger.info("Kotlin JS plugin is already present")
}
registerKScienceExtension(::KScienceExtension)
//logger.info("Applying KScience configuration for JS project")
configure<KotlinJsProjectExtension> {
js(IR) { browser { } }
sourceSets.all {
languageSettings.applySettings()
}
sourceSets["main"].apply {
dependencies {
api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}"))
}
}
sourceSets["test"].apply {
dependencies {
implementation(kotlin("test-js"))
}
}
if (explicitApi == null) explicitApiWarning()
}
(tasks.findByName("processResources") as? Copy)?.apply {
fromJsDependencies("runtimeClasspath")
}
// apply dokka for all projects
if (!plugins.hasPlugin("org.jetbrains.dokka")) {
apply<DokkaPlugin>()
}
}
}

View File

@ -10,12 +10,13 @@ import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.withType import org.gradle.kotlin.dsl.withType
import org.jetbrains.dokka.gradle.DokkaPlugin import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import space.kscience.gradle.internal.applySettings import space.kscience.gradle.internal.applySettings
import space.kscience.gradle.internal.defaultKotlinJvmArgs import space.kscience.gradle.internal.defaultKotlinJvmArgs
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 {
logger.warn("KSCience JVM plugin is deprecated. Use MPP.")
if (!plugins.hasPlugin("org.jetbrains.kotlin.jvm")) { if (!plugins.hasPlugin("org.jetbrains.kotlin.jvm")) {
plugins.apply("org.jetbrains.kotlin.jvm") plugins.apply("org.jetbrains.kotlin.jvm")
} else { } else {
@ -27,6 +28,9 @@ public open class KScienceJVMPlugin : Plugin<Project> {
configure<KotlinJvmProjectExtension> { configure<KotlinJvmProjectExtension> {
sourceSets.all { sourceSets.all {
languageSettings.applySettings() languageSettings.applySettings()
compilerOptions{
freeCompilerArgs.addAll(defaultKotlinJvmArgs)
}
} }
sourceSets["test"].apply { sourceSets["test"].apply {
@ -42,12 +46,6 @@ public open class KScienceJVMPlugin : Plugin<Project> {
} }
} }
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + defaultKotlinJvmArgs
}
}
tasks.withType<Test> { tasks.withType<Test> {
useJUnitPlatform() useJUnitPlatform()
} }

View File

@ -7,8 +7,11 @@ import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
import space.kscience.gradle.KScienceVersions import space.kscience.gradle.KScienceVersions
internal val defaultKotlinJvmArgs: List<String> = internal val defaultKotlinJvmArgs: List<String> = listOf(
listOf("-Xjvm-default=all", "-Xlambdas=indy"/* "-Xjdk-release=${KScienceVersions.JVM_TARGET}"*/) "-Xjvm-default=all",
"-Xlambdas=indy",
/* "-Xjdk-release=${KScienceVersions.JVM_TARGET}"*/
)
internal fun resolveKotlinVersion(): KotlinVersion { internal fun resolveKotlinVersion(): KotlinVersion {
val (major, minor, patch) = KScienceVersions.kotlinVersion.split(".", "-") val (major, minor, patch) = KScienceVersions.kotlinVersion.split(".", "-")
@ -23,6 +26,7 @@ internal fun LanguageSettingsBuilder.applySettings(
apiVersion = versionString apiVersion = versionString
progressiveMode = true progressiveMode = true
optIn("kotlin.RequiresOptIn") optIn("kotlin.RequiresOptIn")
optIn("kotlin.ExperimentalUnsignedTypes") optIn("kotlin.ExperimentalUnsignedTypes")
optIn("kotlin.ExperimentalStdlibApi") optIn("kotlin.ExperimentalStdlibApi")

View File

@ -8,9 +8,7 @@ import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.* import org.gradle.kotlin.dsl.*
import org.gradle.plugins.signing.SigningExtension import org.gradle.plugins.signing.SigningExtension
import org.gradle.plugins.signing.SigningPlugin import org.gradle.plugins.signing.SigningPlugin
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.targets
import space.kscience.gradle.isInDevelopment import space.kscience.gradle.isInDevelopment
internal fun Project.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String internal fun Project.requestPropertyOrNull(propertyName: String): String? = findProperty(propertyName) as? String
@ -24,17 +22,6 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
plugins.withId("maven-publish") { plugins.withId("maven-publish") {
configure<PublishingExtension> { configure<PublishingExtension> {
plugins.withId("org.jetbrains.kotlin.js") {
val kotlin: KotlinJsProjectExtension = extensions.findByType()!!
publications.create<MavenPublication>("js") {
kotlin.targets.flatMap { it.components }.forEach {
from(it)
}
}
}
plugins.withId("org.jetbrains.kotlin.jvm") { plugins.withId("org.jetbrains.kotlin.jvm") {
val kotlin = extensions.findByType<KotlinJvmProjectExtension>()!! val kotlin = extensions.findByType<KotlinJvmProjectExtension>()!!
@ -46,9 +33,7 @@ internal fun Project.setupPublication(mavenPomConfiguration: MavenPom.() -> Unit
} }
publications.create<MavenPublication>("jvm") { publications.create<MavenPublication>("jvm") {
project.components.forEach { from(project.components["java"])
from(it)
}
artifact(sourcesJar) artifact(sourcesJar)
} }