Skip to content

Commit

Permalink
Upgrade to support Kotlin 2.1 (#415)
Browse files Browse the repository at this point in the history
* Upgrade to support Kotlin 2.1

Not working yet, still getting a symbol error.

* Remove offending kotlinter from gradle classpath

* Update to ktlint 1.5.0
  • Loading branch information
jeremymailen authored Dec 9, 2024
1 parent 19ef1fe commit c4ae1fd
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ plugins {

| kotlinter version | min kotlin version | max kotlin version | min gradle version |
|-------------------|--------------------|--------------------|--------------------|
| 4.5.0+ | 2.0.0 | - | 8.4 |
| 4.5.0+ | 2.0.0 | 2.0.21 | 8.4 |
| 4.2.0+ | 1.9.20 | 1.9.25 | 8.4 |
| 4.0.0+ | 1.9.0 | 1.9.25 | 7.6 |
| 3.14.0+ | 1.8.0 | 1.8.22 | 7.6 |
Expand Down Expand Up @@ -319,7 +319,7 @@ Alternatively, if you have a custom build convention plugin that utilizes kotlin

```kotlin
dependencies {
implementation(platform("com.pinterest.ktlint:ktlint-bom:1.2.1"))
implementation(platform("com.pinterest.ktlint:ktlint-bom:1.4.0"))
implementation("org.jmailen.gradle:kotlinter-gradle:4.5.0")
}

Expand Down
24 changes: 13 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

plugins {
`java-gradle-plugin`
`maven-publish`
idea
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.gradle.publish)
alias(libs.plugins.kotlinter)
// Remove temporarily until 2.1.0 compatibility is released
// alias(libs.plugins.kotlinter)
}

repositories {
Expand All @@ -20,7 +23,7 @@ val githubUrl = "https://github.com/jeremymailen/kotlinter-gradle"
val webUrl = "https://github.com/jeremymailen/kotlinter-gradle"
val projectDescription = "Lint and formatting for Kotlin using ktlint with configuration-free setup on JVM and Android projects"

version = "5.0.0-M1"
version = "5.0.0-M2"
group = "org.jmailen.gradle"
description = projectDescription

Expand Down Expand Up @@ -83,15 +86,14 @@ tasks {
dependsOn(generateVersionProperties)
}

val targetJavaVersion = JavaVersion.VERSION_1_8
withType<JavaCompile>().configureEach {
options.release.set(targetJavaVersion.majorVersion.toInt())
options.release.set(JavaVersion.VERSION_1_8.majorVersion.toInt())
}
withType<KotlinCompile>().configureEach {
kotlinOptions {
apiVersion = "1.8"
languageVersion = "1.8"
jvmTarget = targetJavaVersion.toString()
withType<KotlinJvmCompile>().configureEach {
compilerOptions {
apiVersion.set(KotlinVersion.KOTLIN_1_8)
languageVersion.set(KotlinVersion.KOTLIN_1_8)
jvmTarget.set(JvmTarget.JVM_1_8)
}
}
withType<Test>().configureEach {
Expand All @@ -104,7 +106,7 @@ tasks {
}

wrapper {
gradleVersion = "8.11"
gradleVersion = "8.11.1"
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
kotlin = "2.0.21"
ktlint = "1.4.1"
kotlin = "2.1.0"
ktlint = "1.5.0"
android-tools = "7.3.1"
junit = "5.11.3"
mockito = "4.1.0"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion test-project-android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("android") version "2.0.21"
kotlin("android") version "2.1.0"
id("com.android.library")
id("org.jmailen.kotlinter")
}
Expand Down
2 changes: 1 addition & 1 deletion test-project/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plugins {
kotlin("jvm") version "2.0.21"
kotlin("jvm") version "2.1.0"
id("org.jmailen.kotlinter")
}

0 comments on commit c4ae1fd

Please sign in to comment.