https://kotlinlang.org logo
#kapt
Title
# kapt
m

Marc Knaup

05/09/2019, 1:21 PM
What did change in recent kapt/Kotlin/Gradle updates which causes that annotation processors are no longer being run when using a
project
kapt dependency? old (Gradle 5.2.1, Kotlin 1.3.21)
Copy code
kapt(project(":fluid-json-annotation-processor"))
runs kapt just fine using processor from different subproject new (Gradle 5.4.1 with modules, Kotlin 1.3.31)
Copy code
kapt(project(":fluid-json-annotation-processor", "compile"))
annotation processor is not used anymore and no error 😕
Note that without specifying the
compile
configuration I get this error:
Copy code
Execution failed for task ':fluid-json-examples:kaptGenerateStubsKotlin'.
> Could not resolve all files for configuration ':fluid-json-examples:kapt'.
   > Could not resolve com.github.fluidsonic:fluid-stdlib:0.9.4.
     Required by:
         project :fluid-json-examples > project :fluid-json-annotation-processor
      > Cannot choose between the following variants of com.github.fluidsonic:fluid-stdlib:0.9.4:
          - jvm-api
          - jvm-runtime
          - metadata-api
        All of them match the consumer attributes:
          - Variant 'jvm-api' capability com.github.fluidsonic:fluid-stdlib:0.9.4:
              - Unmatched attributes:
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.gradle.usage 'java-api-jars' but wasn't required.
                  - Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
          - Variant 'jvm-runtime' capability com.github.fluidsonic:fluid-stdlib:0.9.4:
              - Unmatched attributes:
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.gradle.usage 'java-runtime-jars' but wasn't required.
                  - Found org.jetbrains.kotlin.platform.type 'jvm' but wasn't required.
          - Variant 'metadata-api' capability com.github.fluidsonic:fluid-stdlib:0.9.4:
              - Unmatched attributes:
                  - Found org.gradle.status 'release' but wasn't required.
                  - Found org.gradle.usage 'kotlin-api' but wasn't required.
                  - Found org.jetbrains.kotlin.platform.type 'common' but wasn't required.
Alright, it only runs with the
default
configuration, not
compile
. So this is actually a Gradle issue where I needed to work around the error above. This helps, but no idea why it's necessary:
Copy code
implementation(fluid("meta-jvm", "0.9.7")) {
	exclude("com.github.fluidsonic", "fluid-stdlib-jvm")
}
implementation(fluid("stdlib-jvm", "0.9.4")) {
	attributes {
		attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)
	}
}
2 Views