Customizeable jdk version
This commit is contained in:
parent
4bfd042f96
commit
1e3018275d
@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Easier dependency handling in `kscience` block
|
- Easier dependency handling in `kscience` block
|
||||||
|
- Customizable base jdk version
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- MPP does not use JVM and JS(IR) targets anymore. They could be turned manually via `js()`, `jvm()` or `fullStack()`
|
- MPP does not use JVM and JS(IR) targets anymore. They could be turned manually via `js()`, `jvm()` or `fullStack()`
|
||||||
|
@ -3,8 +3,10 @@ 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.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
|
||||||
|
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
import org.gradle.language.jvm.tasks.ProcessResources
|
import org.gradle.language.jvm.tasks.ProcessResources
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||||
@ -44,8 +46,17 @@ public val Project.isInDevelopment: Boolean
|
|||||||
|| version.toString().endsWith("SNAPSHOT")
|
|| version.toString().endsWith("SNAPSHOT")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private const val defaultJdkVersion = 11
|
||||||
|
|
||||||
public open class KScienceExtension(public val project: Project) {
|
public open class KScienceExtension(public val project: Project) {
|
||||||
|
|
||||||
|
public val jdkVersionProperty: Property<Int> = project.objects.property<Int>().apply {
|
||||||
|
set(defaultJdkVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
public var jdkVersion: Int by jdkVersionProperty
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use coroutines-core with default version or [version]
|
* Use coroutines-core with default version or [version]
|
||||||
*/
|
*/
|
||||||
@ -337,7 +348,7 @@ public open class KScienceMppExtension(project: Project) : KScienceExtension(pro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
jvmToolchain {
|
jvmToolchain {
|
||||||
languageVersion.set(KScienceVersions.JVM_TARGET)
|
languageVersion.set(jdkVersionProperty.map { JavaLanguageVersion.of(it) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
project.tasks.withType<Test> {
|
project.tasks.withType<Test> {
|
||||||
|
@ -3,6 +3,7 @@ package space.kscience.gradle
|
|||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.tasks.testing.Test
|
import org.gradle.api.tasks.testing.Test
|
||||||
|
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||||
import org.gradle.kotlin.dsl.apply
|
import org.gradle.kotlin.dsl.apply
|
||||||
import org.gradle.kotlin.dsl.configure
|
import org.gradle.kotlin.dsl.configure
|
||||||
import org.gradle.kotlin.dsl.get
|
import org.gradle.kotlin.dsl.get
|
||||||
@ -20,7 +21,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")
|
||||||
}
|
}
|
||||||
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> {
|
||||||
@ -37,7 +38,7 @@ public open class KScienceJVMPlugin : Plugin<Project> {
|
|||||||
|
|
||||||
if (explicitApi == null) explicitApiWarning()
|
if (explicitApi == null) explicitApiWarning()
|
||||||
jvmToolchain {
|
jvmToolchain {
|
||||||
languageVersion.set(KScienceVersions.JVM_TARGET)
|
languageVersion.set(extension.jdkVersionProperty.map { JavaLanguageVersion.of(it) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package space.kscience.gradle
|
package space.kscience.gradle
|
||||||
|
|
||||||
|
|
||||||
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
|
||||||
import org.tomlj.Toml
|
import org.tomlj.Toml
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,8 +23,6 @@ public object KScienceVersions {
|
|||||||
public val jsBom: String get() = toml.getString("versions.jsBom")!!
|
public val jsBom: String get() = toml.getString("versions.jsBom")!!
|
||||||
internal val junit: String get() = toml.getString("versions.junit")!!
|
internal val junit: String get() = toml.getString("versions.junit")!!
|
||||||
|
|
||||||
public val JVM_TARGET: JavaLanguageVersion = JavaLanguageVersion.of(11)
|
|
||||||
|
|
||||||
public object Serialization {
|
public object Serialization {
|
||||||
public val xmlVersion: String get() = toml.getString("versions.xmlutil")!!
|
public val xmlVersion: String get() = toml.getString("versions.xmlutil")!!
|
||||||
public val yamlKtVersion: String get() = toml.getString("versions.yamlkt")!!
|
public val yamlKtVersion: String get() = toml.getString("versions.yamlkt")!!
|
||||||
|
Loading…
Reference in New Issue
Block a user