Skip to content

Commit

Permalink
Bump Kotlin to 2.0.0 (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
mars885 authored Sep 24, 2024
1 parent cbd813d commit 4b908cc
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 13 deletions.
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ repositories {
}

dependencies {
implementation("com.android.tools.build:gradle:8.1.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25")
implementation("com.android.tools.build:gradle:8.3.1")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0")
// See https://github.com/google/dagger/issues/3068#issuecomment-999118496
// for why it should be here.
implementation("com.squareup:javapoet:1.13.0")
Expand Down
16 changes: 8 additions & 8 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ object appConfig {

const val exportableLibJavaCompatVersion = 8

val androidModuleJavaCompatVersion = JavaVersion.VERSION_17
val androidModuleKotlinCompatVersion = JavaVersion.VERSION_17
val androidModuleJavaCompatVersion = JavaVersion.VERSION_1_8
val androidModuleKotlinCompatVersion = JavaVersion.VERSION_1_8
}

object publishingConfig {
Expand Down Expand Up @@ -66,14 +66,14 @@ object publishingConfig {

object versions {

const val kotlin = "1.9.25" // also in buildSrc build.gradle.kts file
const val gradlePlugin = "8.1.0" // also in buildSrc build.gradle.kts file
const val kotlin = "2.0.0" // also in buildSrc build.gradle.kts file
const val androidPlugin = "8.3.1" // also in buildSrc build.gradle.kts file
const val detektPlugin = "1.23.6"
const val ktlintPlugin = "12.1.1"
const val gradleVersionsPlugin = "0.51.0"
const val dokkaPlugin = "1.9.20"
const val shadowPlugin = "8.0.0"
const val ksp = "1.9.25-1.0.20"
const val ksp = "2.0.0-1.0.24"
const val dagger = "2.51.1"
const val appCompat = "1.7.0"
const val navigation = "2.7.7"
Expand All @@ -88,7 +88,7 @@ object versions {
const val ktlint = "1.3.1"
const val jUnit = "4.13.2"
const val truth = "1.4.4"
const val ktCompileTesting = "1.6.0"
const val ktCompileTesting = "0.5.1"
const val testParamInjector = "1.16"
}

Expand All @@ -97,7 +97,7 @@ object deps {
object plugins {

const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
const val android = "com.android.tools.build:gradle:${versions.gradlePlugin}"
const val android = "com.android.tools.build:gradle:${versions.androidPlugin}"
const val ksp = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:${versions.ksp}"
const val daggerHilt = "com.google.dagger:hilt-android-gradle-plugin:${versions.dagger}"
const val gradleVersions = "com.github.ben-manes:gradle-versions-plugin:${versions.gradleVersionsPlugin}"
Expand Down Expand Up @@ -140,6 +140,6 @@ object deps {
const val kspApi = "com.google.devtools.ksp:symbol-processing-api:${versions.ksp}"
const val jUnit = "junit:junit:${versions.jUnit}"
const val truth = "com.google.truth:truth:${versions.truth}"
const val kspCompileTesting = "com.github.tschuchortdev:kotlin-compile-testing-ksp:${versions.ktCompileTesting}"
const val kspCompileTesting = "dev.zacsweers.kctfork:ksp:${versions.ktCompileTesting}"
const val testParamInjector = "com.google.testparameterinjector:test-parameter-injector:${versions.testParamInjector}"
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
25 changes: 25 additions & 0 deletions hilt-binder-compiler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,31 @@ configurations {
}
}

// https://github.com/ZacSweers/kotlin-compile-testing?tab=readme-ov-file#java-16-compatibility
if (JavaVersion.current() >= JavaVersion.VERSION_16) {
tasks.withType<Test>().configureEach {
// Kotlin Compile Testing lib does not run the Javac tests with the JDK 1.8 as of the
// 0.5.1 version. This is a workaround to run the tests using the JDK 17.
// See https://github.com/ZacSweers/kotlin-compile-testing/issues/277
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}

jvmArgs(
"--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
)
}
}

dependencies {
implementation(project(deps.local.hiltBinder))
shadowed(project(deps.local.compilerProcessing))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import com.tschuchort.compiletesting.KotlinCompilation.ExitCode
import com.tschuchort.compiletesting.SourceFile
import com.tschuchort.compiletesting.SourceFile.Companion.java
import com.tschuchort.compiletesting.SourceFile.Companion.kotlin
import com.tschuchort.compiletesting.configureKsp
import com.tschuchort.compiletesting.kspSourcesDir
import com.tschuchort.compiletesting.symbolProcessorProviders
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -5746,10 +5746,13 @@ internal class HiltBinderTest {
sources = sourceFiles
verbose = false
inheritClassPath = true
languageVersion = "1.9"

when (processorType) {
ProcessorType.JAVAC -> annotationProcessors = listOf(HiltBinderJavacProcessor())
ProcessorType.KSP -> symbolProcessorProviders = listOf(HiltBinderKspProcessor.Provider())
ProcessorType.KSP -> configureKsp {
symbolProcessorProviders.add(HiltBinderKspProcessor.Provider())
}
}
}

Expand Down

0 comments on commit 4b908cc

Please sign in to comment.