Martin Brehovsky
10/26/2022, 6:40 PM@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FIELD)
@Retention(AnnotationRetention.RUNTIME)
annotation class CustomAnnotation(
val value: Boolean = true
)
@JvmInline
value class ValueStringClass(
val value: String
)
data class InlineClassTest(
@CustomAnnotation
val stringValue: ValueStringClass,
@CustomAnnotation
val anotherStringValue: String
)
In my AP I can get the annotation for anotherStringValue
of type String
, but there is no annotation present for stringValue
of type ValueStringClass
which is a value class. When I debugged this, I don't see stringValue
exposed as a regular property from the class. Here's what I get from my AP when getting the type elements and their annotation mirrors for the `InlineClassTest`:
element 'stringValue', kind 'FIELD', annotationMirrors '@org.jetbrains.annotations.NotNull'
element 'anotherStringValue', kind 'FIELD', annotationMirrors '@org.jetbrains.annotations.NotNull'
element 'equals', kind 'METHOD', annotationMirrors '@java.lang.Override'
element 'hashCode', kind 'METHOD', annotationMirrors '@java.lang.Override'
element 'toString', kind 'METHOD', annotationMirrors '@org.jetbrains.annotations.NotNull,@java.lang.Override'
element '<init>', kind 'CONSTRUCTOR', annotationMirrors ''
element 'component2', kind 'METHOD', annotationMirrors '@org.jetbrains.annotations.NotNull'
element 'getAnotherStringValue', kind 'METHOD', annotationMirrors '@org.jetbrains.annotations.NotNull'
element 'getAnotherStringValue$annotations', kind 'METHOD', annotationMirrors '@com.doordash.protobuf.mapper.test.CustomAnnotation,@java.lang.Deprecated'
Unfortunately the code depends on 3rd party library which switched from using a wrapper around a String to a value class representing the string. Is there anything I can do to make the value class type to behave like a regular class from the AP perspective? Or something else to look for in the AP to get the annotation associated with that field in the data class? Thx!Odin
11/06/2022, 6:29 PMJerv Norsk
02/21/2023, 12:21 PMdependencies {
kapt("org.mapstruct:mapstruct-processor:latest.release")
}
Sha Sha Chu
03/03/2023, 5:49 PMThe following annotation processors are not incremental: kotlin-compiler-embeddable-1.7.10.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.7.10).
Make sure all annotation processors are incremental to improve your build speed.
Sha Sha Chu
03/15/2023, 2:29 PMMarek Kubiczek
03/16/2023, 8:21 PMBrais Gabin
04/27/2023, 3:27 PMkapt
task after I change an argument in the extensions?
kapt {
arguments {
arg("foo", "bar") // I change "bar" for anything else and kapt is not reexecuted.
}
}
juliocbcotta
05/10/2023, 10:02 AMGavin Ray
08/06/2023, 5:02 PMKaptOptions.Builder()
API has an argument for passing options to javac
, but it expects Map<String, String>
Does anyone know how you can pass arguments like --enable-preview
which don't have an -flag=X
value?
public final class KaptOptions : org.jetbrains.kotlin.base.kapt3.KaptFlags {
// ...
public final class Builder public constructor() {
// ...
public final val javacOptions: kotlin.collections.MutableMap<kotlin.String, kotlin.String> /* compiled code */
I tried to search Github code usage and dug through hundreds of repos, but I couldn't find a single one which passes an argument like --enable-preview
to Kapt
kevin.cianfarini
08/29/2023, 2:33 PMkapt
does not seem to see sources in our commonMain
sourceset when generating stubs for android after the upgrade to Kotlin 1.9.0. In Kotlin 1.8.22 stubs were generated for everything in the androidMain
sourceset and the commonMain
sourceset, but after upgrading to 1.9.0 we’re only seeing stubs generated for the androidMain
sourceset.
Does anyone have any tips on how we might begin to debut this? How does kapt locate source files to generate stubs for?Brais Gabin
09/14/2023, 10:08 AMgenerated/source/kapt
on the configuration of my task but it doesn't look safe. Is there something on the kapt gradle api I can use to get that path?Anders Carlsen
09/16/2023, 10:42 AMExecution failed for task ':moduleName:kaptKotlinJvm'.
> Cannot query the value of this provider because it has no value available.
The value of this provider is derived from:
- task ':moduleName:kaptGenerateStubsKotlinJvm' property 'kotlinCompileDestinationDirectory'
If I remove Kapt plugin it works on jvm, but the Hilt kapt tasks won’t be run and I get runtime error when using viewModel on Android.
this is the build.gradle.kts file:
plugins {
kotlin("multiplatform")
id("com.android.library")
kotlin("kapt")
}
kotlin {
jvm()
androidTarget()
sourceSets {
val commonMain by getting {
dependencies {
implementation(Deps.kotlinCoroutines)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting {
dependencies {
implementation(Deps.voyagerNavigator)
implementation(Deps.voyagerKoin)
}
}
val androidMain by getting {
kotlin.srcDir("src/commonMain/kotlin")
dependencies {
implementation(Deps.kotlinCoroutinesAndroid)
implementation(Deps.androidxLifecycleViewModel)
implementation(Deps.googleHilt)
configurations["kapt"]?.dependencies?.add(project.dependencies.create(Deps.googleHiltCompiler))
}
}
}
}
android {
namespace = "package"
compileSdk = ConfigData.androidCompileSdkVersion
defaultConfig {
minSdk = ConfigData.androidMinSdkVersion
}
sourceSets["main"].apply {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
res.srcDirs("src/androidMain/resources")
resources.srcDirs("src/commonMain/resources")
}
compileOptions {
sourceCompatibility = Versions.javaVersion
targetCompatibility = Versions.javaVersion
}
kotlin {
jvmToolchain(Versions.javaJvmTarget.toInt())
}
}
Mattia Tommasone
09/19/2023, 4:26 PM> Task :modules:mockk-agent-android:dokkaJavadoc FAILED
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':modules:mockk-agent-android:dokkaJavadoc' (type 'DokkaTask').
- Gradle detected a problem with the following location: '/Users/raibaz/dev/mockk/modules/mockk-agent-android/build/tmp/kapt3/classes/release'.
Reason: Task ':modules:mockk-agent-android:dokkaJavadoc' uses this output of task ':modules:mockk-agent-android:kaptReleaseKotlin' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
1. Declare task ':modules:mockk-agent-android:kaptReleaseKotlin' as an input of ':modules:mockk-agent-android:dokkaJavadoc'.
2. Declare an explicit dependency on ':modules:mockk-agent-android:kaptReleaseKotlin' from ':modules:mockk-agent-android:dokkaJavadoc' using Task#dependsOn.
3. Declare an explicit dependency on ':modules:mockk-agent-android:kaptReleaseKotlin' from ':modules:mockk-agent-android:dokkaJavadoc' using Task#mustRunAfter.
Thing is, I don’t know how to declare an explicit dependency on kaptReleaseKotlin
Any pointers?statmark56
09/29/2023, 12:46 PMBrais Gabin
11/13/2023, 10:07 AMval project = ProjectBuilder.builder()
.build()
project.pluginManager.apply(KotlinPluginWrapper::class.java)
project.pluginManager.apply(Kapt3GradleSubplugin::class.java)
project.pluginManager.apply(LightsaberPlugin::class.java)
I can see the tasks generated by kotlin and my plugin but I can't see any task generated by kapt. This makes that my tests pointless because want I want is to assert that the tasks that my plugin adds depends on the correct kapt tasks (for example, that :lightsaberDebugCheck
depends on :kaptDebugKotlin
). I have some tests using GradleRunner
but those tests are way slower and I can't assert the dependencies I just can assert that "X" task was executed without knowing the reason. Is there a way to make this work with ProjectBuilder
? Any other idea to how to test this?eygraber
11/23/2023, 7:28 PMPlugin [id: 'org.jetbrains.kotlin.kapt'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (plugin dependency must include a version number for this source)
It was working fine before like this:
plugins {
kotlin("kapt")
}
It seems to work if I manually add the version:
plugins {
kotlin("kapt") version "1.9.20"
}
scana
12/22/2023, 11:42 AMtestDebug
task is being called.
Using Anvil right now with generateDaggerFactories
flag for regular app building flow but we have to use kaptTest
to build local Dagger components in tests.
I feel like this causes unnecessary stub generation tasks to run for regular compilation and was wondering if I could get rid of it somehow while keeping KAPT in tests. think smartZac Sweers
12/30/2023, 3:46 AMZac Sweers
12/30/2023, 3:55 AMRahul
01/01/2024, 5:26 AMimplementation('org.mapstruct:mapstruct:1.5.5.Final')
kapt('org.mapstruct:mapstruct-processor:1.5.5.Final')
Wanted to know if there is a way to restrict the annotation processing to be applied only to src code produced by the us and exclude the 3rd party libraries.ritesh
01/31/2024, 5:24 PM1.9.21
and dagger - 2.48.1
Antoni Zwolski
02/10/2024, 6:23 PMAntoni Zwolski
02/11/2024, 10:45 PMWARNING: An illegal reflective access operation has occurred
and
Execution failed for task ':modules:backend-api:category:category-api:kaptGenerateStubsTestKotlin'.
> java.io.IOException: The system cannot find the path specified
Antoni Zwolski
02/15/2024, 3:46 PMYurii Surzhykov
02/29/2024, 7:08 PM@PersitableEvent
, which is used to annotate the class for which my KSP plugin have to generate entity class, mapper class, DAO interface and there is also autogenerated database class with all those DAOs.
The situation is the following, let's assume there is a class
@PersitableEvent
data class PreviouslyCreatedClass(
val someProperty: String
)
The problem is next. When I'm trying to compile everything from scratch(without '_build/generated'_ folder), everything works as expected, each class is generated and everything compiles and runs. But then, I'm adding a new class with @PersitableEvent
annotation, and ksp task completes successfully, but kapt shows me error:
kaptGenerateStubsDebugKotlin: Unresolved reference PreviouslyCreatedClassDao
in my AutoGeneratedDatabase class.
And there is also message below this error:
kaptGenerateStubsDebugKotlin: Failed to restore task output as snapshot file app/build/snapshot/kotlin/kaptGenerateStubsDebugKotlin/2.zip does not exist!
I don't understand what is wrong with it, but when I compile again, it compiles successfully(maybe because second time it compiles everything from scratch and not uses cache).
Can someone explain me what the error means, and how to solve it?
Currently I removed kapt plugin and the error is disappeared but I would probably need kapt in the future(for dagger).
P.s. PreviouslyCreatedClassDao
is an autogenerated class
P.p.s My Kotlin version is 1.9.20, and ksp version is 1.9.20.-1.0.14Dmytro Serdiuk
02/29/2024, 11:42 PMBerkeli Alashov
08/05/2024, 10:56 PMw: Kapt currently doesn't support language version 2.0+. Falling back to 1.9.
in logs means it applies only for kapt right? i.e rest of the project is using kotlin 2.0, but kapt itself is falling back kotlin 1.9?
Context: we have upgraded most of our modules to use kotlin 2.0 & ksp, but only 2 modules are using id("kotlin-kapt")
(because of room-java)
I'm guessing we will still be able to use kotlin 2.0 in those modules using kotlin-kapt, right?Suyash
09/17/2024, 6:49 AMcompile
value in KAPT's aptMode
? If so, how do you use it, and what would be the impact if it were deprecated?”rkeazor
10/11/2024, 10:58 AMedrd
12/05/2024, 3:02 PM