diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index 3fee781d..c11d5ca9 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -6,7 +6,6 @@ plugins { kotlin("kapt") id("library") id("library.publishing") - id("com.gradleup.shadow") `java-test-fixtures` } @@ -18,18 +17,15 @@ dependencies { implementation(libs.dagger) implementation(libs.dagger.hilt.core) implementation(libs.ksp.api) - implementation(libs.auto.common) + api(libs.auto.common) + implementation(libs.kotlin.metadata) implementation(projects.core) implementation(projects.android.testing) implementation(projects.thirdParty.androidx.room) implementation(projects.thirdParty.ktorfit) implementation(projects.thirdParty.retrofit) - implementation(projects.compiler.common) - compileShaded(libs.kotlinx.metadata) { - exclude("org.jetbrains.kotlin", "kotlin-stdlib") - } implementation(libs.auto.service.annotations) kapt(libs.auto.service) @@ -41,4 +37,5 @@ dependencies { testFixturesApi(libs.dagger) testFixturesApi(libs.dagger.hilt.core) testFixturesApi(libs.bundles.compileTesting) + testFixturesApi(projects.compiler.common) } \ No newline at end of file diff --git a/compiler/common/build.gradle.kts b/compiler/common/build.gradle.kts index cd11ccfd..80c66dd4 100644 --- a/compiler/common/build.gradle.kts +++ b/compiler/common/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } dependencies { - compileOnly(libs.kotlinx.metadata) + compileOnly(libs.kotlin.metadata) compileOnly(libs.javapoet) compileOnly(libs.bundles.kotlinpoet) implementation(libs.dagger) diff --git a/compiler/common/test-utils/build.gradle.kts b/compiler/common/test-utils/build.gradle.kts index e1ec27e3..0d0250e0 100644 --- a/compiler/common/test-utils/build.gradle.kts +++ b/compiler/common/test-utils/build.gradle.kts @@ -6,10 +6,10 @@ plugins { } dependencies { - api(projects.compiler.common.apply { targetConfiguration = "shadow" }) + api(projects.compiler.common) api(libs.bundles.jvmTesting) api(libs.dagger.hilt.core) - api(libs.kotlinx.metadata) + api(libs.kotlin.metadata) api(libs.ksp.api) api(libs.bundles.compileTesting) api(libs.okio) diff --git a/compiler/src/main/kotlin/se/ansman/dagger/auto/compiler/kapt/processing/KaptClassDeclaration.kt b/compiler/src/main/kotlin/se/ansman/dagger/auto/compiler/kapt/processing/KaptClassDeclaration.kt index 7a1ed4c0..00feea1f 100644 --- a/compiler/src/main/kotlin/se/ansman/dagger/auto/compiler/kapt/processing/KaptClassDeclaration.kt +++ b/compiler/src/main/kotlin/se/ansman/dagger/auto/compiler/kapt/processing/KaptClassDeclaration.kt @@ -4,12 +4,12 @@ import com.google.auto.common.MoreElements import com.squareup.javapoet.AnnotationSpec import com.squareup.javapoet.ClassName import com.squareup.javapoet.TypeName -import kotlinx.metadata.ClassKind -import kotlinx.metadata.Modality -import kotlinx.metadata.Visibility -import kotlinx.metadata.kind -import kotlinx.metadata.modality -import kotlinx.metadata.visibility +import kotlin.metadata.ClassKind +import kotlin.metadata.Modality +import kotlin.metadata.Visibility +import kotlin.metadata.kind +import kotlin.metadata.modality +import kotlin.metadata.visibility import se.ansman.dagger.auto.compiler.common.processing.ClassDeclaration import javax.lang.model.element.Element import javax.lang.model.element.ElementKind diff --git a/compiler/src/main/kotlin/se/ansman/dagger/auto/compiler/kapt/processing/KaptResolver.kt b/compiler/src/main/kotlin/se/ansman/dagger/auto/compiler/kapt/processing/KaptResolver.kt index ce3d8ea2..bb03f51e 100644 --- a/compiler/src/main/kotlin/se/ansman/dagger/auto/compiler/kapt/processing/KaptResolver.kt +++ b/compiler/src/main/kotlin/se/ansman/dagger/auto/compiler/kapt/processing/KaptResolver.kt @@ -5,7 +5,7 @@ import com.google.common.collect.ImmutableSetMultimap import com.squareup.javapoet.AnnotationSpec import com.squareup.javapoet.ClassName import com.squareup.javapoet.TypeName -import kotlinx.metadata.jvm.KotlinClassMetadata +import kotlin.metadata.jvm.KotlinClassMetadata import se.ansman.dagger.auto.compiler.common.TypeLookup import se.ansman.dagger.auto.compiler.common.processing.AutoDaggerResolver import se.ansman.dagger.auto.compiler.common.processing.ClassDeclaration diff --git a/compiler/src/testFixtures/kotlin/se/ansman/dagger/auto/compiler/KspCompilation.kt b/compiler/src/testFixtures/kotlin/se/ansman/dagger/auto/compiler/KspCompilation.kt index f2098ebc..5ab57036 100644 --- a/compiler/src/testFixtures/kotlin/se/ansman/dagger/auto/compiler/KspCompilation.kt +++ b/compiler/src/testFixtures/kotlin/se/ansman/dagger/auto/compiler/KspCompilation.kt @@ -28,22 +28,9 @@ class KspCompilation( symbolProcessorProviders.addAll(processorProviders()) } } - .compileFixed() + .compile() .let(::Result) - private fun KotlinCompilation.compileFixed(): JvmCompilationResult { - return compile() -// val result = synchronized(mutex) { compile() } -// // This works around a bug where compile-testing-kotlin returns OK even though KSP failed. -// if ( -// result.exitCode == KotlinCompilation.ExitCode.OK && -// "e: Error occurred in KSP, check log for detail" in result.messages -// ) { -// return JvmCompilationResult(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.messages, this, ) -// } -// return result - } - private fun File.listSourceFiles(): Sequence = walkTopDown().filter { it.isFile && (it.extension == "java" || it.extension == "kt") } @@ -51,7 +38,7 @@ class KspCompilation( get() = workingDir.resolve("ksp/sources").listSourceFiles() class Factory(vararg processorProviders: () -> SymbolProcessorProvider) : Compilation.Factory { - private val processorProviders = { processorProviders.map { it() }} + private val processorProviders = { processorProviders.map { it() } } override val expectedFilesDirectoryName: String get() = "ksp" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3f2e0437..0819d6e7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] -kotlin = "2.0.21" +kotlin = "2.1.0" dokka = "1.9.20" -compileTesting = "0.6.0" +compileTesting = "0.7.0" autoService = "1.1.1" incap = "1.0.0" dagger = "2.52" -ksp = "2.0.21-1.0.28" +ksp = "2.1.0-1.0.29" android-minSdk = "21" android-compileSdk = "35" androidx-test = "1.6.1" @@ -28,7 +28,7 @@ kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotl kotlin-jvm-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } kotlin-compiler-embeddable = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable", version.ref = "kotlin" } -kotlinx-metadata = "org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.9.0" +kotlin-metadata = { module = "org.jetbrains.kotlin:kotlin-metadata-jvm", version.ref = "kotlin" } dokka-gradlePlugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" } dokka-versioningPlugin = { module = "org.jetbrains.dokka:versioning-plugin", version.ref = "dokka" } diff --git a/tests/build.gradle.kts b/tests/build.gradle.kts index 4f09ca11..ed3aa95b 100644 --- a/tests/build.gradle.kts +++ b/tests/build.gradle.kts @@ -5,6 +5,7 @@ import com.android.build.api.variant.HasTestFixturesBuilder import com.android.build.api.variant.HasUnitTestBuilder import com.android.build.gradle.internal.lint.AndroidLintAnalysisTask import com.google.devtools.ksp.gradle.KspTask +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion plugins { id("com.android.application") @@ -32,6 +33,14 @@ android { } } +kotlin { + compilerOptions { + // Needed until Hilt supports Kotlin 2.1: + // https://github.com/google/dagger/issues/4451 + languageVersion = KotlinVersion.KOTLIN_2_0 + } +} + androidComponents { beforeVariants { variant -> (variant as? HasAndroidTestBuilder)?.androidTest?.enable = variant.buildType == "debug" @@ -47,8 +56,8 @@ ksp { dependencies { implementation(libs.retrofit.moshi) implementation(libs.dagger.hilt.android) - "kaptJava"(projects.compiler) { targetConfiguration = "shadow" } - "kspKotlin"(projects.compiler) { targetConfiguration = "shadow" } + "kaptJava"(projects.compiler) + "kspKotlin"(projects.compiler) "kaptJava"(libs.dagger.compiler) "kspKotlin"(libs.dagger.compiler) "kaptJava"(libs.dagger.hilt.compiler) @@ -70,8 +79,8 @@ dependencies { // Unit test testImplementation(libs.dagger.hilt.android.testing) - "kaptTestJava"(projects.compiler) { targetConfiguration = "shadow" } - "kspTestKotlin"(projects.compiler) { targetConfiguration = "shadow" } + "kaptTestJava"(projects.compiler) + "kspTestKotlin"(projects.compiler) // Compile Only is used here to ensure it's included by the android module testCompileOnly(libs.androidx.startup) "kaptTestJava"(libs.dagger.compiler)