Skip to content

Commit 1997604

Browse files
committed
build: extract language config constants
1 parent 5af5e83 commit 1997604

File tree

4 files changed

+44
-16
lines changed

4 files changed

+44
-16
lines changed

build-logic/src/main/kotlin/modelix-kotlin-jvm.gradle.kts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1+
2+
import org.modelix.MODELIX_JDK_VERSION
3+
import org.modelix.MODELIX_JVM_TARGET
24

35
/*
46
* Copyright (c) 2024.
@@ -22,8 +24,8 @@ plugins {
2224
}
2325

2426
kotlin {
25-
jvmToolchain(11)
27+
jvmToolchain(MODELIX_JDK_VERSION)
2628
compilerOptions {
27-
jvmTarget.set(JvmTarget.JVM_11)
29+
jvmTarget.set(MODELIX_JVM_TARGET)
2830
}
2931
}

build-logic/src/main/kotlin/modelix-kotlin-multiplatform.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.modelix.MODELIX_JDK_VERSION
2+
13
/*
24
* Copyright (c) 2024.
35
*
@@ -20,7 +22,7 @@ plugins {
2022
}
2123

2224
kotlin {
23-
jvmToolchain(11)
25+
jvmToolchain(MODELIX_JDK_VERSION)
2426
js(IR) {
2527
browser {
2628
testTask {

build-logic/src/main/kotlin/modelix-language-config.gradle.kts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,58 +15,58 @@
1515
*/
1616

1717
import gradle.kotlin.dsl.accessors._9d6accdeac6876c73060866945fb6d8c.java
18-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1918
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
2019
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
21-
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
2220
import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper
2321
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin
2422
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2523
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
24+
import org.modelix.MODELIX_JDK_VERSION
25+
import org.modelix.MODELIX_JVM_TARGET
26+
import org.modelix.MODELIX_KOTLIN_API_VERSION
2627

2728
java {
2829
toolchain {
29-
languageVersion.set(JavaLanguageVersion.of(11))
30+
languageVersion.set(JavaLanguageVersion.of(MODELIX_JDK_VERSION))
3031
}
3132
}
3233

33-
val kotlinApiVersion = KotlinVersion.KOTLIN_1_6
3434
tasks.withType<KotlinCompile>().configureEach {
3535
if (!name.lowercase().contains("test")) {
3636
this.compilerOptions {
37-
jvmTarget.set(JvmTarget.JVM_11)
37+
jvmTarget.set(MODELIX_JVM_TARGET)
3838
freeCompilerArgs.addAll(listOf("-Xjvm-default=all-compatibility", "-Xexpect-actual-classes"))
39-
apiVersion.set(kotlinApiVersion)
39+
apiVersion.set(MODELIX_KOTLIN_API_VERSION)
4040
}
4141
}
4242
}
4343

4444
tasks.withType<KotlinJvmCompile>().configureEach {
4545
if (!name.lowercase().contains("test")) {
4646
this.compilerOptions {
47-
jvmTarget.set(JvmTarget.JVM_11)
47+
jvmTarget.set(MODELIX_JVM_TARGET)
4848
freeCompilerArgs.addAll(listOf("-Xjvm-default=all-compatibility"))
49-
apiVersion.set(kotlinApiVersion)
49+
apiVersion.set(MODELIX_KOTLIN_API_VERSION)
5050
}
5151
}
5252
}
5353

5454
plugins.withType<KotlinPlatformJvmPlugin> {
5555
extensions.configure<KotlinJvmProjectExtension> {
56-
jvmToolchain(11)
56+
jvmToolchain(MODELIX_JDK_VERSION)
5757
compilerOptions {
58-
jvmTarget.set(JvmTarget.JVM_11)
58+
jvmTarget.set(MODELIX_JVM_TARGET)
5959
}
6060
}
6161
}
6262

6363
plugins.withType<KotlinMultiplatformPluginWrapper> {
6464
extensions.configure<KotlinMultiplatformExtension> {
65-
jvmToolchain(11)
65+
jvmToolchain(MODELIX_JDK_VERSION)
6666
sourceSets.all {
6767
if (!name.lowercase().contains("test")) {
6868
languageSettings {
69-
apiVersion = kotlinApiVersion.version
69+
apiVersion = MODELIX_KOTLIN_API_VERSION.version
7070
}
7171
}
7272
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2024.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.modelix
18+
19+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
20+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
21+
22+
const val MODELIX_JDK_VERSION = 11
23+
val MODELIX_JVM_TARGET = JvmTarget.JVM_11
24+
val MODELIX_KOTLIN_API_VERSION = KotlinVersion.KOTLIN_1_6

0 commit comments

Comments
 (0)