diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ddbed93a0..fffff4a57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - kotlin-version: [ 1.9.24 ] + kotlin-version: [ 2.0.21 ] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 @@ -36,7 +36,7 @@ jobs: strategy: fail-fast: false matrix: - kotlin-version: [ 1.9.24 ] + kotlin-version: [ 2.0.21 ] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 @@ -162,8 +162,8 @@ jobs: # solution. fail-fast: false matrix: - kotlin-version: [ 1.9.24 ] - agp-version: [ 7.1.1, 7.2.0, 7.3.1 ] + kotlin-version: [ 2.0.21 ] + agp-version: [ 7.2.0, 7.3.1 ] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 @@ -194,7 +194,7 @@ jobs: # solution. fail-fast: false matrix: - kotlin-version: [ 1.9.24 ] + kotlin-version: [ 2.0.21 ] steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 diff --git a/annotations-optional/dependencies/runtimeClasspath.txt b/annotations-optional/dependencies/runtimeClasspath.txt index 838ee9d83..b4f3e56ab 100644 --- a/annotations-optional/dependencies/runtimeClasspath.txt +++ b/annotations-optional/dependencies/runtimeClasspath.txt @@ -1,3 +1,3 @@ javax.inject:javax.inject:1 -org.jetbrains.kotlin:kotlin-stdlib:1.9.24 +org.jetbrains.kotlin:kotlin-stdlib:2.0.21 org.jetbrains:annotations:13.0 diff --git a/annotations/dependencies/runtimeClasspath.txt b/annotations/dependencies/runtimeClasspath.txt index ecec3fda5..8b9b920b5 100644 --- a/annotations/dependencies/runtimeClasspath.txt +++ b/annotations/dependencies/runtimeClasspath.txt @@ -1,2 +1,2 @@ -org.jetbrains.kotlin:kotlin-stdlib:1.9.24 +org.jetbrains.kotlin:kotlin-stdlib:2.0.21 org.jetbrains:annotations:13.0 diff --git a/build-logic/conventions/src/main/kotlin/com/squareup/anvil/conventions/BasePlugin.kt b/build-logic/conventions/src/main/kotlin/com/squareup/anvil/conventions/BasePlugin.kt index 710ca7e91..7ef8e6414 100644 --- a/build-logic/conventions/src/main/kotlin/com/squareup/anvil/conventions/BasePlugin.kt +++ b/build-logic/conventions/src/main/kotlin/com/squareup/anvil/conventions/BasePlugin.kt @@ -108,6 +108,11 @@ abstract class BasePlugin : Plugin { } freeCompilerArgs.addAll(extension.kotlinCompilerArgs.get()) + // We do not yet support K2, and KAPT + Kotlin 2.0 generates a warning about falling back to + // language version 1.9. Because we treat all warnings as errors, we need to suppress this + // specific warning to not fail the build. Related YT ticket: + // https://youtrack.jetbrains.com/issue/KT-68400/K2-w-Kapt-currently-doesnt-support-language-version-2.0.-Falling-back-to-1.9. + freeCompilerArgs.add("-Xsuppress-version-warnings") fun isTestSourceSet(): Boolean { val regex = """(?:gradle|Unit|[aA]ndroid)Test""".toRegex() diff --git a/compiler-api/dependencies/runtimeClasspath.txt b/compiler-api/dependencies/runtimeClasspath.txt index ab38ea102..750bcfd16 100644 --- a/compiler-api/dependencies/runtimeClasspath.txt +++ b/compiler-api/dependencies/runtimeClasspath.txt @@ -1,8 +1,9 @@ org.jetbrains.intellij.deps:trove4j:1.0.20200330 -org.jetbrains.kotlin:kotlin-bom:1.9.24 -org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.24 -org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.24 -org.jetbrains.kotlin:kotlin-reflect:1.9.24 -org.jetbrains.kotlin:kotlin-script-runtime:1.9.24 -org.jetbrains.kotlin:kotlin-stdlib:1.9.24 +org.jetbrains.kotlin:kotlin-bom:2.0.21 +org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21 +org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21 +org.jetbrains.kotlin:kotlin-reflect:2.0.21 +org.jetbrains.kotlin:kotlin-script-runtime:2.0.21 +org.jetbrains.kotlin:kotlin-stdlib:2.0.21 +org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 org.jetbrains:annotations:13.0 diff --git a/compiler-api/src/main/java/com/squareup/anvil/compiler/api/AnvilCompilationException.kt b/compiler-api/src/main/java/com/squareup/anvil/compiler/api/AnvilCompilationException.kt index 94eaa82ac..55162aec7 100644 --- a/compiler-api/src/main/java/com/squareup/anvil/compiler/api/AnvilCompilationException.kt +++ b/compiler-api/src/main/java/com/squareup/anvil/compiler/api/AnvilCompilationException.kt @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.symbols.IrSymbol +import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI import org.jetbrains.kotlin.ir.util.render import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi import org.jetbrains.kotlin.resolve.source.KotlinSourceElement @@ -114,6 +115,7 @@ public class AnvilCompilationException( message: String, cause: Throwable? = null, ): AnvilCompilationException { + @OptIn(UnsafeDuringIrConstructionAPI::class) return AnvilCompilationException( message = message, cause = cause, diff --git a/compiler-utils/dependencies/runtimeClasspath.txt b/compiler-utils/dependencies/runtimeClasspath.txt index 1f0b5b680..5fcc1ddcb 100644 --- a/compiler-utils/dependencies/runtimeClasspath.txt +++ b/compiler-utils/dependencies/runtimeClasspath.txt @@ -1,12 +1,14 @@ -com.google.dagger:dagger:2.51.1 -com.squareup:kotlinpoet-jvm:1.16.0 -com.squareup:kotlinpoet:1.16.0 +com.google.dagger:dagger:2.52 +com.squareup:kotlinpoet-jvm:1.18.1 +com.squareup:kotlinpoet:1.18.1 +jakarta.inject:jakarta.inject-api:2.0.1 javax.inject:javax.inject:1 org.jetbrains.intellij.deps:trove4j:1.0.20200330 -org.jetbrains.kotlin:kotlin-bom:1.9.24 -org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.24 -org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.24 -org.jetbrains.kotlin:kotlin-reflect:1.9.24 -org.jetbrains.kotlin:kotlin-script-runtime:1.9.24 -org.jetbrains.kotlin:kotlin-stdlib:1.9.24 +org.jetbrains.kotlin:kotlin-bom:2.0.21 +org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21 +org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21 +org.jetbrains.kotlin:kotlin-reflect:2.0.21 +org.jetbrains.kotlin:kotlin-script-runtime:2.0.21 +org.jetbrains.kotlin:kotlin-stdlib:2.0.21 +org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 org.jetbrains:annotations:13.0 diff --git a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilation.kt b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilation.kt index 34ea24331..a4086b76a 100644 --- a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilation.kt +++ b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilation.kt @@ -20,6 +20,7 @@ import dagger.internal.codegen.ComponentProcessor import dagger.internal.codegen.KspComponentProcessor import org.intellij.lang.annotations.Language import org.jetbrains.kotlin.config.JvmTarget +import org.jetbrains.kotlin.config.LanguageVersion import java.io.File import java.io.OutputStream import java.nio.file.Files @@ -46,7 +47,7 @@ public class AnvilCompilation internal constructor( disableComponentMerging: Boolean = false, enableExperimentalAnvilApis: Boolean = true, trackSourceFiles: Boolean = true, - mode: AnvilCompilationMode = Embedded(emptyList()), + mode: AnvilCompilationMode = Embedded(), enableAnvil: Boolean = true, ): AnvilCompilation = apply { checkNotCompiled() @@ -306,7 +307,7 @@ public fun compileAnvil( enableExperimentalAnvilApis: Boolean = true, trackSourceFiles: Boolean = true, previousCompilationResult: JvmCompilationResult? = null, - mode: AnvilCompilationMode = Embedded(emptyList()), + mode: AnvilCompilationMode = Embedded(), moduleName: String? = null, jvmTarget: JvmTarget? = null, expectExitCode: KotlinCompilation.ExitCode? = null, @@ -315,6 +316,8 @@ public fun compileAnvil( return AnvilCompilation() .apply { kotlinCompilation.apply { + languageVersion = LanguageVersion.KOTLIN_1_9.versionString + apiVersion = LanguageVersion.KOTLIN_1_9.versionString this.allWarningsAsErrors = allWarningsAsErrors this.messageOutputStream = messageOutputStream if (workingDir != null) { diff --git a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilationMode.kt b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilationMode.kt index 9bd888415..d253afabd 100644 --- a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilationMode.kt +++ b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilationMode.kt @@ -9,7 +9,6 @@ import com.squareup.anvil.compiler.api.CodeGenerator public sealed class AnvilCompilationMode(public val analysisBackend: AnalysisBackend) { public data class Embedded( val codeGenerators: List = emptyList(), - val useDagger: Boolean = false, ) : AnvilCompilationMode(EMBEDDED) public data class Ksp( val symbolProcessorProviders: List = emptyList(), diff --git a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/TestUtils.kt b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/TestUtils.kt index aded1f261..7ddc4e865 100644 --- a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/TestUtils.kt +++ b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/TestUtils.kt @@ -11,7 +11,7 @@ import dagger.Component import dagger.Module import dagger.Provides import dagger.Subcomponent -import org.jetbrains.kotlin.analysis.utils.collections.mapToSet +import org.jetbrains.kotlin.utils.mapToSetOrEmpty import kotlin.reflect.KClass @ExperimentalAnvilApi @@ -29,7 +29,7 @@ public fun Class<*>.moduleFactoryClass( val providesMethods = methodsOrCompanionMethods .filter { it.isAnnotationPresent(Provides::class.java) } - .mapToSet { it.name } + .mapToSetOrEmpty { it.name } assertWithMessage("No @Provides methods found in $this") .that(providesMethods) diff --git a/compiler/dependencies/runtimeClasspath.txt b/compiler/dependencies/runtimeClasspath.txt index f34ff5d9a..eb6147190 100644 --- a/compiler/dependencies/runtimeClasspath.txt +++ b/compiler/dependencies/runtimeClasspath.txt @@ -1,14 +1,16 @@ -com.google.dagger:dagger:2.51.1 -com.squareup:kotlinpoet-jvm:1.16.0 -com.squareup:kotlinpoet-ksp:1.16.0 -com.squareup:kotlinpoet:1.16.0 +com.google.dagger:dagger:2.52 +com.squareup:kotlinpoet-jvm:1.18.1 +com.squareup:kotlinpoet-ksp:1.18.1 +com.squareup:kotlinpoet:1.18.1 +jakarta.inject:jakarta.inject-api:2.0.1 javax.annotation:jsr250-api:1.0 javax.inject:javax.inject:1 org.jetbrains.intellij.deps:trove4j:1.0.20200330 -org.jetbrains.kotlin:kotlin-bom:1.9.24 -org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.24 -org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.24 -org.jetbrains.kotlin:kotlin-reflect:1.9.24 -org.jetbrains.kotlin:kotlin-script-runtime:1.9.24 -org.jetbrains.kotlin:kotlin-stdlib:1.9.24 +org.jetbrains.kotlin:kotlin-bom:2.0.21 +org.jetbrains.kotlin:kotlin-compiler-embeddable:2.0.21 +org.jetbrains.kotlin:kotlin-daemon-embeddable:2.0.21 +org.jetbrains.kotlin:kotlin-reflect:2.0.21 +org.jetbrains.kotlin:kotlin-script-runtime:2.0.21 +org.jetbrains.kotlin:kotlin-stdlib:2.0.21 +org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 org.jetbrains:annotations:13.0 diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/IrContributionMerger.kt b/compiler/src/main/java/com/squareup/anvil/compiler/IrContributionMerger.kt index c4b0d0cb6..e432e9d1f 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/IrContributionMerger.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/IrContributionMerger.kt @@ -26,6 +26,7 @@ import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrVararg +import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI import org.jetbrains.kotlin.ir.types.classFqName import org.jetbrains.kotlin.ir.types.classOrFail import org.jetbrains.kotlin.ir.types.classOrNull @@ -49,6 +50,7 @@ import java.io.File * as super types to Dagger components annotated with `@MergeComponent` or `@MergeSubcomponent`. * This also supports arbitrary interface merging on interfaces annotated with `@MergeInterfaces`. */ +@OptIn(org.jetbrains.kotlin.backend.common.extensions.FirIncompatiblePluginAPI::class) internal class IrContributionMerger( private val classScanner: ClassScanner, private val moduleDescriptorFactory: RealAnvilModuleDescriptor.Factory, @@ -160,6 +162,7 @@ internal class IrContributionMerger( irMergesFile.writeText(mergedText) } + @OptIn(UnsafeDuringIrConstructionAPI::class) private fun IrBuilderWithScope.addMergedModules( annotations: List, moduleFragment: IrModuleFragment, @@ -378,6 +381,7 @@ internal class IrContributionMerger( contributedModules: Sequence, annotations: List, ): IrConstructorCall { + @OptIn(UnsafeDuringIrConstructionAPI::class) return irCallConstructor( callee = pluginContext .referenceConstructors(daggerAnnotationFqName.classIdBestGuess()) @@ -628,6 +632,7 @@ internal class IrContributionMerger( // Since we are modifying the state of the code here, this does not need to be reflected in // the associated [ClassReferenceIr] which is more of an initial snapshot. + @OptIn(UnsafeDuringIrConstructionAPI::class) clazz.owner.superTypes += toAdd // Return the list of added supertypes diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/IrUtils.kt b/compiler/src/main/java/com/squareup/anvil/compiler/IrUtils.kt index 084d1523f..9480be202 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/IrUtils.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/IrUtils.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationWithName import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol +import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI import org.jetbrains.kotlin.ir.types.IrSimpleType import org.jetbrains.kotlin.ir.types.classifierOrNull import org.jetbrains.kotlin.ir.types.typeOrNull @@ -38,6 +39,7 @@ internal fun IrClass.requireClassId(): ClassId { ) } +@OptIn(UnsafeDuringIrConstructionAPI::class) internal fun IrClassSymbol.requireClassId(): ClassId = owner.requireClassId() internal val IrExpression.kclassUnwrapped: IrClassifierSymbol @@ -53,6 +55,7 @@ internal val IrDeclarationWithName.fqName: FqName element = this, ) +@OptIn(UnsafeDuringIrConstructionAPI::class) internal val IrClassSymbol.fqName: FqName get() = owner.fqName // If we're evaluating an anonymous inner class, it cannot merge anything and will cause diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationArgumentReferenceIr.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationArgumentReferenceIr.kt index e34695edb..2769578ef 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationArgumentReferenceIr.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationArgumentReferenceIr.kt @@ -7,6 +7,7 @@ import org.jetbrains.kotlin.ir.declarations.IrValueParameter import org.jetbrains.kotlin.ir.expressions.IrConst import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrVararg +import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI import kotlin.LazyThreadSafetyMode.NONE internal class AnnotationArgumentReferenceIr( @@ -25,6 +26,7 @@ internal class AnnotationArgumentReferenceIr( // We currently special-case for Classes, but this is the spot we'll need to update if we need to // support primitives later on. + @OptIn(UnsafeDuringIrConstructionAPI::class) private fun findValue(): Any { (argumentExpression as? IrConst<*>)?.let { return it.value as Any diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationReferenceIr.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationReferenceIr.kt index 9d725a3dc..683848c95 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationReferenceIr.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationReferenceIr.kt @@ -4,6 +4,7 @@ import com.squareup.anvil.compiler.api.AnvilCompilationException import com.squareup.anvil.compiler.internal.reference.AnnotationReference import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext import org.jetbrains.kotlin.ir.expressions.IrConstructorCall +import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI import org.jetbrains.kotlin.ir.util.getArgumentsWithIr import org.jetbrains.kotlin.ir.util.parentAsClass import org.jetbrains.kotlin.name.FqName @@ -83,6 +84,7 @@ internal class AnnotationReferenceIr( } } +@OptIn(UnsafeDuringIrConstructionAPI::class) internal fun IrConstructorCall.toAnnotationReference( context: IrPluginContext, declaringClass: ClassReferenceIr?, diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/ClassReferenceIr.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/ClassReferenceIr.kt index 3eddd1a5a..a3ebb9cad 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/ClassReferenceIr.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/ClassReferenceIr.kt @@ -13,12 +13,15 @@ import org.jetbrains.kotlin.backend.common.lower.parents import org.jetbrains.kotlin.descriptors.DescriptorVisibilities import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI import org.jetbrains.kotlin.ir.util.isInterface import org.jetbrains.kotlin.ir.util.packageFqName +import org.jetbrains.kotlin.ir.util.parents import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import kotlin.LazyThreadSafetyMode.NONE +@OptIn(UnsafeDuringIrConstructionAPI::class) internal class ClassReferenceIr( val clazz: IrClassSymbol, val context: IrPluginContext, @@ -31,6 +34,7 @@ internal class ClassReferenceIr( get() = fqName.shortName().asString() val enclosingClassesWithSelf: List by lazy { + @OptIn(UnsafeDuringIrConstructionAPI::class) clazz.owner.parents .filterIsInstance() .map { it.symbol.toClassReference(context) } diff --git a/gradle-plugin/dependencies/runtimeClasspath.txt b/gradle-plugin/dependencies/runtimeClasspath.txt index ecec3fda5..8b9b920b5 100644 --- a/gradle-plugin/dependencies/runtimeClasspath.txt +++ b/gradle-plugin/dependencies/runtimeClasspath.txt @@ -1,2 +1,2 @@ -org.jetbrains.kotlin:kotlin-stdlib:1.9.24 +org.jetbrains.kotlin:kotlin-stdlib:2.0.21 org.jetbrains:annotations:13.0 diff --git a/gradle-plugin/src/main/java/com/squareup/anvil/plugin/AnvilPlugin.kt b/gradle-plugin/src/main/java/com/squareup/anvil/plugin/AnvilPlugin.kt index c23d45781..1bf074f73 100644 --- a/gradle-plugin/src/main/java/com/squareup/anvil/plugin/AnvilPlugin.kt +++ b/gradle-plugin/src/main/java/com/squareup/anvil/plugin/AnvilPlugin.kt @@ -113,15 +113,21 @@ internal open class AnvilPlugin : KotlinCompilerPluginSupportPlugin { override fun applyToCompilation( kotlinCompilation: KotlinCompilation<*>, ): Provider> { - kotlinCompilation.compilerOptions.options.let { - @Suppress("DEPRECATION") - val useK2 = it.useK2.get() - if (useK2 || it.languageVersion.getOrElse(KOTLIN_1_9) >= KOTLIN_2_0) { - kotlinCompilation.project.logger - .error( - "NOTE: Anvil is currently incompatible with the K2 compiler. Related GH issue:" + - "https://github.com/square/anvil/issues/733", - ) + kotlinCompilation.compileTaskProvider.configure { action -> + action.compilerOptions.let { + @Suppress("DEPRECATION") + val useK2 = it.useK2.get() + if (useK2 || it.languageVersion.getOrElse(KOTLIN_1_9) >= KOTLIN_2_0) { + kotlinCompilation.project.logger + .warn( + "NOTE: Anvil is currently incompatible with the K2 compiler and the language " + + "version will be overridden to 1.9. Related GH issue:" + + "https://github.com/square/anvil/issues/733", + ) + } + + it.languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9) + it.apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_9) } } diff --git a/gradle.properties b/gradle.properties index ff7a05276..81bd3a8b7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -49,3 +49,5 @@ android.defaults.buildfeatures.viewBinding=false # Suppress the warning about MPP being in alpha. kotlin.mpp.stability.nowarn=true + +kotlin.languageVersion=1.9 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0d1a6aabd..ad8d970a8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,7 +19,7 @@ autoService = "1.1.1" autoValue = "1.11.0" buildconfig = "5.4.0" classgraph = "4.8.174" -dagger = "2.51.1" +dagger = "2.52" dropbox-dependencyGuard = "0.5.0" dokka = "1.9.20" espresso = "3.5.1" @@ -29,14 +29,14 @@ jvm-toolchain = "17" jvm-target-library = "8" jvm-target-minimal = "11" kase = "0.11.1" -kct = "0.4.0" +kct = "0.5.1" kgx = "0.1.12" kotest = "5.9.1" -kotlin = "1.9.24" +kotlin = "2.0.21" kotlinx-binaryCompatibility = "0.16.2" -kotlinpoet = "1.16.0" +kotlinpoet = "1.18.1" # If updating KSP version, we currently have ksp override logic in settings.gradle that needs to be updated too -ksp = "1.9.24-1.0.20" +ksp = "2.0.21-1.0.25" ktlint = "1.0.1" ktlintPlugin = "12.1.1" mavenPublish = "0.29.0"