0.15.4-2.0.0

This commit is contained in:
Alexander Nozik 2024-06-04 12:49:18 +03:00
parent ec3e3e3376
commit 43dcf509fb
5 changed files with 22 additions and 14 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -21,7 +21,7 @@ public open class KScienceMPPlugin : Plugin<Project> {
logger.info("Kotlin MPP plugin is already present") logger.info("Kotlin MPP plugin is already present")
} }
registerKScienceExtension(::KScienceMppExtension) val kscience = registerKScienceExtension<KScienceMppExtension>()
configure<KotlinMultiplatformExtension> { configure<KotlinMultiplatformExtension> {
sourceSets { sourceSets {
@ -46,6 +46,12 @@ public open class KScienceMPPlugin : Plugin<Project> {
} }
if (explicitApi == null) explicitApiWarning() 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"))
}
} }