Skip to content

Commit 6f71c73

Browse files
committed
build: Introduce Kotlin Gradle Convention Plugin
Likely only one consumer: `:lint-rules`, added to standardize .kts files `kotlin-library` is intended for our modules which target `java-library` Issue 20775 Assisted-by: Claude Opus 4.7
1 parent e6a3006 commit 6f71c73

2 files changed

Lines changed: 39 additions & 15 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
// TODO: create a kotlin-library for future pure-kotlin libraries
20+
// lint-rules did not need this.
21+
22+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
23+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
24+
25+
plugins {
26+
id("org.jetbrains.kotlin.jvm")
27+
}
28+
29+
tasks.withType(JavaCompile::class).configureEach {
30+
sourceCompatibility = JavaVersion.VERSION_17.toString()
31+
targetCompatibility = JavaVersion.VERSION_17.toString()
32+
}
33+
34+
tasks.withType(KotlinCompile::class).configureEach {
35+
compilerOptions {
36+
jvmTarget = JvmTarget.JVM_17
37+
}
38+
}

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)