zalewski.se
05/31/2020, 6:57 AMdependsOn
relation for the source sets. Let’s say I have structure like this:
sourceSets {
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutines_version")
}
val androidMain by getting {
dependsOn(commonMain)
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
implementation("com.android.support:support-compat:28.0.0")
}
}
In such scenario, androidMain
will get from the commonMain
everything, including the coroutines-core-common
? (But I don’t think I need this as in androidMain
I have coroutines-core
) Isn’t it better to declare exact dependencies for every source set than use dependsOn
?kevin
05/31/2020, 1:22 PMkevin
05/31/2020, 1:22 PMkevin
05/31/2020, 1:23 PMkevin
05/31/2020, 1:24 PMKris Wong
06/01/2020, 12:58 PMdependsOn
is useful for say, common code between 2 iOS targets, or common code between iOS and macOS tagrgetsKris Wong
06/01/2020, 12:58 PMKris Wong
06/01/2020, 12:59 PMzalewski.se
06/01/2020, 1:02 PMKris Wong
06/01/2020, 1:03 PMkevin
06/01/2020, 1:05 PMkevin
06/01/2020, 1:06 PMimplementation project(':businesslogic')
?zalewski.se
06/01/2020, 1:11 PMobviously your target specific source sets automatically depend on your common source sets
Does it work for Android tests too?
I have commonTests
that looks like this
kotlin {
val uniqueName = "${project.rootProject.name}${project.name.capitalize()}"
android()
ios {
binaries {
framework(uniqueName)
}
}
sourceSets {
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation(Koin.test)
}
}
}
}
And still above the kotlin
block I have to put:
dependencies {
testImplementation(kotlin("test", Build.Versions.kotlin))
testImplementation(kotlin("test-junit", Build.Versions.kotlin))
testImplementation(Koin.test)
}
Kris Wong
06/01/2020, 1:25 PM