Skip to content

Commit 90a43a2

Browse files
authored
Merge pull request #961 from modelix/build/deduplicate-kotlin-config
MODELIX-876 Deduplicate Kotlin configuration
2 parents 2480f04 + 9471397 commit 90a43a2

File tree

39 files changed

+239
-403
lines changed

39 files changed

+239
-403
lines changed

authorization/build.gradle.kts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
description = "Library that checks is allowed to do something"
22

33
plugins {
4-
kotlin("jvm")
4+
`modelix-kotlin-jvm-with-junit`
55
kotlin("plugin.serialization")
66
}
77

@@ -22,16 +22,6 @@ dependencies {
2222
testImplementation(kotlin("test"))
2323
}
2424

25-
tasks.getByName<Test>("test") {
26-
useJUnitPlatform()
27-
}
28-
29-
java {
30-
toolchain {
31-
languageVersion.set(JavaLanguageVersion.of(11))
32-
}
33-
}
34-
3525
publishing {
3626
publications {
3727
create<MavenPublication>("maven") {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
import org.gradle.kotlin.dsl.invoke
18+
19+
20+
plugins {
21+
id("modelix-kotlin-jvm")
22+
}
23+
24+
tasks.test {
25+
useJUnitPlatform()
26+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
import org.modelix.MODELIX_JDK_VERSION
18+
import org.modelix.MODELIX_JVM_TARGET
19+
20+
21+
plugins {
22+
kotlin("jvm")
23+
id("modelix-language-config")
24+
}
25+
26+
kotlin {
27+
jvmToolchain(MODELIX_JDK_VERSION)
28+
compilerOptions {
29+
jvmTarget.set(MODELIX_JVM_TARGET)
30+
}
31+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
import org.modelix.MODELIX_JDK_VERSION
18+
19+
plugins {
20+
kotlin("multiplatform")
21+
id("modelix-language-config")
22+
}
23+
24+
kotlin {
25+
jvmToolchain(MODELIX_JDK_VERSION)
26+
js(IR) {
27+
browser {
28+
testTask {
29+
useMocha {
30+
timeout = "60s"
31+
}
32+
}
33+
}
34+
nodejs {
35+
testTask {
36+
useMocha {
37+
timeout = "60s"
38+
}
39+
}
40+
}
41+
useCommonJs()
42+
}
43+
jvm {
44+
testRuns["test"].executionTask.configure {
45+
useJUnitPlatform()
46+
}
47+
}
48+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
import gradle.kotlin.dsl.accessors._9d6accdeac6876c73060866945fb6d8c.java
18+
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
19+
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
20+
import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper
21+
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin
22+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
23+
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
27+
28+
java {
29+
toolchain {
30+
languageVersion.set(JavaLanguageVersion.of(MODELIX_JDK_VERSION))
31+
}
32+
}
33+
34+
tasks.withType<KotlinCompile>().configureEach {
35+
if (!name.lowercase().contains("test")) {
36+
this.compilerOptions {
37+
jvmTarget.set(MODELIX_JVM_TARGET)
38+
freeCompilerArgs.addAll(listOf("-Xjvm-default=all-compatibility", "-Xexpect-actual-classes"))
39+
apiVersion.set(MODELIX_KOTLIN_API_VERSION)
40+
}
41+
}
42+
}
43+
44+
tasks.withType<KotlinJvmCompile>().configureEach {
45+
if (!name.lowercase().contains("test")) {
46+
this.compilerOptions {
47+
jvmTarget.set(MODELIX_JVM_TARGET)
48+
freeCompilerArgs.addAll(listOf("-Xjvm-default=all-compatibility"))
49+
apiVersion.set(MODELIX_KOTLIN_API_VERSION)
50+
}
51+
}
52+
}
53+
54+
plugins.withType<KotlinPlatformJvmPlugin> {
55+
extensions.configure<KotlinJvmProjectExtension> {
56+
jvmToolchain(MODELIX_JDK_VERSION)
57+
compilerOptions {
58+
jvmTarget.set(MODELIX_JVM_TARGET)
59+
}
60+
}
61+
}
62+
63+
plugins.withType<KotlinMultiplatformPluginWrapper> {
64+
extensions.configure<KotlinMultiplatformExtension> {
65+
jvmToolchain(MODELIX_JDK_VERSION)
66+
sourceSets.all {
67+
if (!name.lowercase().contains("test")) {
68+
languageSettings {
69+
apiVersion = MODELIX_KOTLIN_API_VERSION.version
70+
}
71+
}
72+
}
73+
}
74+
}
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

build.gradle.kts

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ import io.gitlab.arturbosch.detekt.Detekt
55
import org.jetbrains.dokka.base.DokkaBase
66
import org.jetbrains.dokka.base.DokkaBaseConfiguration
77
import org.jetbrains.dokka.gradle.DokkaTaskPartial
8-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
9-
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
10-
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
11-
import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper
12-
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin
138

149
buildscript {
1510
dependencies {
@@ -75,58 +70,6 @@ subprojects {
7570
}
7671
}
7772

78-
val kotlinApiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_6
79-
subproject.tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
80-
if (!name.lowercase().contains("test")) {
81-
this.compilerOptions {
82-
jvmTarget.set(JvmTarget.JVM_11)
83-
freeCompilerArgs.addAll(listOf("-Xjvm-default=all-compatibility", "-Xexpect-actual-classes"))
84-
apiVersion.set(kotlinApiVersion)
85-
}
86-
}
87-
}
88-
subproject.tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile>().configureEach {
89-
if (!name.lowercase().contains("test")) {
90-
this.compilerOptions {
91-
jvmTarget.set(JvmTarget.JVM_11)
92-
freeCompilerArgs.addAll(listOf("-Xjvm-default=all-compatibility"))
93-
apiVersion.set(kotlinApiVersion)
94-
}
95-
}
96-
}
97-
98-
subproject.plugins.withType<JavaPlugin> {
99-
subproject.extensions.configure<JavaPluginExtension> {
100-
toolchain {
101-
languageVersion.set(JavaLanguageVersion.of(11))
102-
}
103-
sourceCompatibility = JavaVersion.VERSION_11
104-
targetCompatibility = JavaVersion.VERSION_11
105-
}
106-
}
107-
108-
subproject.plugins.withType<KotlinPlatformJvmPlugin> {
109-
subproject.extensions.configure<KotlinJvmProjectExtension> {
110-
jvmToolchain(11)
111-
compilerOptions {
112-
jvmTarget.set(JvmTarget.JVM_11)
113-
}
114-
}
115-
}
116-
117-
subproject.plugins.withType<KotlinMultiplatformPluginWrapper> {
118-
subproject.extensions.configure<KotlinMultiplatformExtension> {
119-
jvmToolchain(11)
120-
sourceSets.all {
121-
if (!name.lowercase().contains("test")) {
122-
languageSettings {
123-
apiVersion = kotlinApiVersion.version
124-
}
125-
}
126-
}
127-
}
128-
}
129-
13073
subproject.plugins.withType<NodePlugin> {
13174
subproject.extensions.configure<NodeExtension> {
13275
version.set(libs.versions.node)

bulk-model-sync-gradle-test/build.gradle.kts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
plugins {
18-
kotlin("jvm")
18+
`modelix-kotlin-jvm-with-junit`
1919
id("org.modelix.bulk-model-sync")
2020
}
2121

@@ -32,14 +32,6 @@ dependencies {
3232
testImplementation(libs.xmlunit.core)
3333
}
3434

35-
tasks.test {
36-
useJUnitPlatform()
37-
}
38-
39-
kotlin {
40-
jvmToolchain(11)
41-
}
42-
4335
val repoDir = project.layout.buildDirectory.dir("test-repo").get().asFile
4436

4537
val copyTestRepo by tasks.registering(Sync::class) {

bulk-model-sync-gradle-test/graph-lang-api/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id("org.modelix.model-api-gen")
3-
kotlin("jvm")
3+
`modelix-kotlin-jvm-with-junit`
44
}
55

66
repositories {
@@ -30,7 +30,6 @@ kotlin {
3030
sourceSets.named("main") {
3131
kotlin.srcDir(kotlinGenDir)
3232
}
33-
jvmToolchain(11)
3433
}
3534

3635
metamodel {

bulk-model-sync-gradle/build.gradle.kts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
kotlin("jvm")
2+
`modelix-kotlin-jvm-with-junit`
33
`java-gradle-plugin`
44
}
55

@@ -15,10 +15,6 @@ dependencies {
1515
testImplementation(kotlin("test"))
1616
}
1717

18-
kotlin {
19-
jvmToolchain(11)
20-
}
21-
2218
gradlePlugin {
2319
val modelSync by plugins.creating {
2420
id = "org.modelix.bulk-model-sync"

0 commit comments

Comments
 (0)