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
kapt() should accept string type instead Action< KaptExtension >
kapt due an error: kapt("io.requery:requery-processor:$requery_version")
^ Type mismatch: inferred type is String but Action
I want to use kapt multiplatform jvm and js
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val requery_version = "1.5.1"
val rxjava2_version = "2.2.3"
plugins {
kotlin("multiplatform") version "1.3.30"
id("idea")
kotlin("kapt") version "1.3.21"
}
group = "com.cps"
version = "1.0-SNAPSHOT"
repositories {
maven("https://jcenter.bintray.com")
mavenCentral()
}
kotlin{
jvm() // Creates a JVM target with the default name 'jvm'
js() // JS target named 'js'
sourceSets {
jvm().compilations["main"].defaultSourceSet {
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation( "io.vertx:vertx-web:${extra["vertxVersion"]}")
implementation( "io.vertx:vertx-web-client:${extra["vertxVersion"]}")
implementation("io.vertx:vertx-mysql-postgresql-client:${extra["vertxVersion"]}")
implementation("net.postgis:postgis-jdbc:2.2.1")
implementation("javax.cache:cache-api:1.1.0")
implementation("org.ehcache:ehcache:3.5.2")
implementation("io.reactivex.rxjava2:rxjava:$rxjava2_version")
implementation("io.requery:requery:$requery_version")
implementation("io.vertx:vertx-tcp-eventbus-bridge:${extra["vertxVersion"]}")
implementation("io.vertx:vertx-lang-kotlin:${extra["vertxVersion"]}")
implementation("io.vertx:vertx-auth-common:${extra["vertxVersion"]}")
implementation("io.vertx:vertx-auth-oauth2:${extra["vertxVersion"]}")
implementation("io.vertx:vertx-service-discovery:${extra["vertxVersion"]}")
implementation("io.vertx:vertx-circuit-breaker:${extra["vertxVersion"]}")
implementation("io.vertx:vertx-lang-kotlin-coroutines:${extra["vertxVersion"]}")
implementation("io.vertx:vertx-config:${extra["vertxVersion"]}")
implementation("io.vertx:vertx-hazelcast:${extra["vertxVersion"]}")
implementation("org.postgresql:postgresql:9.4-1200-jdbc41")
implementation("io.requery:requery-kotlin:$requery_version")
//implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.0-alpha-2")
implementation("org.slf4j:slf4j-simple:1.7.14")
// kapt("io.requery:requery-processor:$requery_version")
}
}
}
}
dependencies {
kapt("io.requery:requery-processor:$requery_version")
}
gradle --versionVersion 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-default
Version 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
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
kaptis 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
Most helpful comment
@steelxtreme: The suggestion from @eskatos didn't work for me because
kaptis undefined onconfigurations.I wanted a annotation processing from a local dependency and the following worked:
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")) }