0.15.8-kotlin-2.1.0 #51

Merged
altavir merged 54 commits from dev into master 2024-12-09 09:49:38 +03:00
5 changed files with 22 additions and 14 deletions
Showing only changes of commit 43dcf509fb - Show all commits

View File

@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Added
- Pass `compose` extension to the kscience extension so compose dependencies could be called directly from kscience block
### Changed
- Use ES6 modules by default in JS

View File

@ -19,7 +19,7 @@ ktor = "2.3.11"
logback = "1.5.6"
slf4j = "2.0.13"
# @pin
tools = "0.15.3-kotlin-2.0.0"
tools = "0.15.4-kotlin-2.0.0"
xmlutil = "0.86.3"
yamlkt = "0.13.0"
kover = "0.8.0"

View File

@ -3,6 +3,7 @@ package space.kscience.gradle
import org.gradle.api.Project
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.plugins.ApplicationPlugin
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.testing.Test
@ -28,6 +29,7 @@ import space.kscience.gradle.internal.defaultKotlinJvmArgs
import space.kscience.gradle.internal.fromJsDependencies
import space.kscience.gradle.internal.requestPropertyOrNull
import space.kscience.gradle.internal.useCommonDependency
import javax.inject.Inject
public enum class DependencyConfiguration {
API,
@ -52,7 +54,7 @@ public val Project.isInDevelopment: Boolean
private const val defaultJdkVersion = 11
public open class KScienceExtension(public val project: Project) {
public abstract class KScienceExtension @Inject constructor(public val project: Project): ExtensionAware {
public val jdkVersionProperty: Property<Int> = project.objects.property<Int>().apply {
set(defaultJdkVersion)
@ -352,7 +354,8 @@ public class KScienceNativeConfiguration(private val project: Project) {
): Unit = target(KScienceNativeTarget(preset, targetName, targetConfiguration))
}
public open class KScienceMppExtension(project: Project) : KScienceExtension(project) {
public abstract class KScienceMppExtension @Inject constructor(project: Project) : KScienceExtension(project) {
/**
* Enable jvm target
*/
@ -414,10 +417,6 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
*/
@OptIn(ExperimentalWasmDsl::class)
public fun wasm(block: KotlinWasmJsTargetDsl.() -> Unit = {}) {
// if (project.requestPropertyOrNull("kscience.wasm.disabled") == "true") {
// project.logger.warn("Wasm target is disabled with 'kscience.wasm.disabled' property")
// return
// }
project.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
project.configure<KotlinMultiplatformExtension> {
@ -538,9 +537,11 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
}
internal inline fun <reified T : KScienceExtension> Project.registerKScienceExtension(constructor: (Project) -> T): T {
extensions.findByType<T>()?.let { return it }
return constructor(this).also {
extensions.add("kscience", it)
}
internal inline fun <reified T : KScienceExtension> Project.registerKScienceExtension():T {
// extensions.findByType<T>()?.let { return it }
// return constructor(this).also {
// extensions.add("kscience", it)
// }
return extensions.create("kscience", T::class.java)
}

View File

@ -22,7 +22,7 @@ public open class KScienceJVMPlugin : Plugin<Project> {
} else {
logger.info("Kotlin JVM plugin is already present")
}
val extension = registerKScienceExtension(::KScienceExtension)
val extension = registerKScienceExtension<KScienceExtension>()
//logger.info("Applying KScience configuration for JVM project")
configure<KotlinJvmProjectExtension> {

View File

@ -21,7 +21,7 @@ public open class KScienceMPPlugin : Plugin<Project> {
logger.info("Kotlin MPP plugin is already present")
}
registerKScienceExtension(::KScienceMppExtension)
val kscience = registerKScienceExtension<KScienceMppExtension>()
configure<KotlinMultiplatformExtension> {
sourceSets {
@ -46,6 +46,12 @@ public open class KScienceMPPlugin : Plugin<Project> {
}
if (explicitApi == null) explicitApiWarning()
//pass compose extension inside kscience extensions to make it available inside kscience block
plugins.withId("org.jetbrains.compose"){
kscience.extensions.add("compose", (this@configure as org.gradle.api.plugins.ExtensionAware).extensions.getByName("compose"))
}
}