Skip to content

Commit e23f422

Browse files
committed
build: Introduce Kotlin Gradle Convention Plugin
`kotlin-jvm` is intended for our modules which target `java-library` Issue 20775 Assisted-by: Claude Opus 4.7
1 parent fac8958 commit e23f422

3 files changed

Lines changed: 38 additions & 30 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2026 David Allison <davidallisongithub@gmail.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under
5+
* the terms of the GNU General Public License as published by the Free Software
6+
* Foundation; either version 3 of the License, or (at your option) any later
7+
* version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
10+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11+
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License along with
14+
* this program. If not, see <http://www.gnu.org/licenses/>.
15+
*/
16+
17+
// Convention plugin: applies the Kotlin JVM plugin and pins Java/Kotlin
18+
// toolchain settings for pure-JVM (non-Android) modules in this project.
19+
20+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
21+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22+
23+
plugins {
24+
id("org.jetbrains.kotlin.jvm")
25+
}
26+
27+
tasks.withType(JavaCompile::class).configureEach {
28+
sourceCompatibility = JavaVersion.VERSION_17.toString()
29+
targetCompatibility = JavaVersion.VERSION_17.toString()
30+
}
31+
32+
tasks.withType(KotlinCompile::class).configureEach {
33+
compilerOptions {
34+
jvmTarget = JvmTarget.JVM_17
35+
}
36+
}

common/build.gradle.kts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
1-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2-
31
plugins {
4-
// Use `id` to avoid classpath conflicts. Versions are pinned by buildSrc/.
5-
id("org.jetbrains.kotlin.jvm")
2+
id("ankidroid.kotlin-jvm")
63
`java-test-fixtures`
74
}
85

9-
java {
10-
sourceCompatibility = JavaVersion.VERSION_17
11-
targetCompatibility = JavaVersion.VERSION_17
12-
}
13-
14-
kotlin {
15-
compilerOptions {
16-
jvmTarget = JvmTarget.JVM_17
17-
}
18-
}
19-
206
dependencies {
217
implementation(libs.json)
228
implementation(libs.androidx.annotation)

lint-rules/build.gradle.kts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
1-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3-
41
plugins {
5-
id("kotlin")
6-
}
7-
8-
tasks.withType(JavaCompile::class).configureEach {
9-
sourceCompatibility = JavaVersion.VERSION_17.toString()
10-
targetCompatibility = JavaVersion.VERSION_17.toString()
11-
}
12-
13-
tasks.withType(KotlinCompile::class).all {
14-
compilerOptions {
15-
jvmTarget = JvmTarget.JVM_17
16-
}
2+
id("ankidroid.kotlin-jvm")
173
}
184

195
dependencies {

0 commit comments

Comments
 (0)