Closed steelxt closed 5 years ago
In that context, kapt
resolves to the Project
extension registered under the kapt
name by the Kotlin Gradle Plugin. The extension to declare a dependency in the kapt
Configuration
isn't available in the kotlin.sourceSets.jvm().compilations["main"].defaultSourceSet.dependencies {}
scope.
You can work around this in the following ways:
kotlin {
sourceSets {
jvm().compilations["main"].defaultSourceSet {
dependencies {
"kapt"(...)
// or
configurations.kapt(...)
}
}
}
}
Please use the Gradle forums for support questions https://discuss.gradle.org/
@eskatos any reason to not make this extension available ? I bumped into something similar in an android app using the multiplatform plugin.
@steelxtreme: The suggestion from @eskatos didn't work for me because kapt
is undefined on configurations
.
I wanted a annotation processing from a local dependency and the following worked:
dependencies {
configurations.get("kapt").dependencies.add(project("dependency_path"))
}
I haven't tested, but the following may work in your instance for an external dependency:
dependencies {
configurations.get("kapt").dependencies.add(DefaultExternalModuleDependency("io.requery", "requery-processor", "1.5.1"))
}
The suggestion from @eskatos didn't work for me either. I am now trying with :
configurations.get("kapt").dependencies.add(DefaultExternalModuleDependency("com.google.dagger", "dagger-compiler", "2.24"))
But I am getting the following error:
Could not determine the dependencies of task ':api:social-cats:kaptKotlinJvm'.
> Could not resolve all task dependencies for configuration ':api:social-cats:_classStructurekaptKotlinJvm'.
> Could not resolve project :search:model.
Required by:
project :api:social-cats
> Cannot choose between the following variants of project :search:model:
- jsApiElements
- jsCompile
- jsCompileOnly
- jsDefault
- jsRuntime
- jsRuntimeElements
- jsTestCompile
- jsTestRuntime
- jvmApiElements
- jvmCompile
- jvmCompileOnly
- jvmDefault
- jvmRuntime
- jvmRuntimeElements
- jvmTestCompile
- jvmTestRuntime
- metadataApiElements
- metadataCompile
- metadataCompileOnly
- metadataDefault
@niqo01 This is a separate issue.
If your Gradle plugin cannot determine the correct configuration for the dependency automatically then you need to specify the configuration manually [1]:
implementation project(path: ':search:model', configuration: 'jvmDefault')
[1] Note: The above is in Groovy. You'll need to translate it to Kotlin for your project.
@steelxtreme: The suggestion from @eskatos didn't work for me because
kapt
is undefined onconfigurations
.I wanted a annotation processing from a local dependency and the following worked:
dependencies { configurations.get("kapt").dependencies.add(project("dependency_path")) }
I haven't tested, but the following may work in your instance for an external dependency:
dependencies { configurations.get("kapt").dependencies.add(DefaultExternalModuleDependency("io.requery", "requery-processor", "1.5.1")) }
That was very very hard to find. I struggled for a weak before I stumbled upon this. I have even sacrificed 90% of my reputation on stackoverflow to get this answer... https://stackoverflow.com/questions/59321848/using-kapt-with-multiplatform-subproject
I'm trying to build fullstack project with vert.x+ requery and kotlin js in the front, but I can't setup kapt due an error: kapt("io.requery:requery-processor:$requery_version") ^ Type mismatch: inferred type is String but Action< KaptExtension > was expected
Expected Behavior
kapt() should accept string type instead Action< KaptExtension >
Current Behavior
kapt due an error: kapt("io.requery:requery-processor:$requery_version") ^ Type mismatch: inferred type is String but Action was expected
Context
I want to use kapt multiplatform jvm and js
Steps to Reproduce (for bugs)
Your Environment
Build scan URL:
gradle --version
5.3Version of IntelliJ or Android Studio (in
About
menu you can copy version information) IntelliJ IDEA 2019.1 (Community Edition) Build #IC-191.6183.87, built on March 27, 2019 JRE: 1.8.0_202-release-1483-b39 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 4.4.176-96-defaultVersion of the Kotlin Plugin used in IntelliJ or Android Studio (in the
Configure Kotlin Plugin Updates
preference panel) 1.3.30-release-IJ2019.1-1