Hi,
I would like to know if it is possible to use both Java and Kotlin to run tests against jvm target along with android target in a Kotlin multiplatform project.
I am trying out Jetbrains compose for desktop in order to share business domain and some UI components with desktop (jvm) and android.
I tried to use cucumber tests in order to to run automated acceptance tests. And for now I am able to run cucumber tests with Kotlin.
But since cucumber is not yet supported for kotlin, I rely on cucumber-jvm to run my tests (which is fine for me).
I would like to have better IDE support (with Gherkin plugin) for generating and maintaining my gherkin features.
When I add withJava
in my jvm target in common sub module, I get the following error :
The ‘java’ plugin has been applied, but it is not compatible with the Android plugins.
common/build.gradle.kts
import org.jetbrains.compose.compose
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose") version "0.1.0-m1-build62"
id("com.android.library")
id("kotlin-android-extensions")
}
group = "fr.baldir.dashboard"
version = "1.0"
repositories {
google()
}
kotlin {
android(){
}
jvm("desktop") {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
withJava() // allows to use java code (in tests)
//https://discuss.kotlinlang.org/t/koltlin-1-3-61-multi-platform-project-default-idea-project-not-able-to-run-java-test-in-jvmtests/15962/3
}
sourceSets {
val commonMain by getting {
dependencies {
api(compose.runtime)
api(compose.foundation)
api(compose.material)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidMain by getting {
dependencies {
api("androidx.appcompat:appcompat:1.2.0")
api("androidx.core:core-ktx:1.3.2")
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13")
}
}
val desktopMain by getting
val desktopTest by getting {
dependencies {
implementation("io.cucumber:cucumber-java8:6.8.1")
implementation("io.cucumber:cucumber-junit:6.8.1")
implementation("org.junit.jupiter:junit-jupiter:5.7.0")
implementation("org.junit.vintage:junit-vintage-engine:5.7.0")
}
}
}
}
android {
compileSdkVersion(29)
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdkVersion(24)
targetSdkVersion(28)
}
}