Hello everyone, how do I include all the `androidM...
# multiplatform
r
Hello everyone, how do I include all the
androidMain
dependencies into
androidTest
? Should I just copy/paste them or is there a better method to do it, like a reference?
l
Aren't they already available? I think
androidTest
depends on
androidMain
, is that the case?
r
It doesn't look like that, it seems they are indipendent
g
Looks like some issue (not sure on which level, build.gradle, MPP plugin or Android Gradle)
This is how it should work out of the box, if it doesn’t would be good to reproduce it and report an issue to Kotlin issue tracker, most probably it’s some MPP plugin problem
n
I don’t know whether it’s a bug or a feature, but a solution to your question would be a
configure
block.
g
it’s not a feature
n
Copy code
sourceSets {
        all {
            languageSettings {
                languageVersion = '1.3'
                useExperimentalAnnotation 'kotlin.ExperimentalUnsignedTypes'
            }
        }
        commonMain {
            dependencies {
                implementation kotlin('stdlib-common')
                implementation "io.ktor:ktor-client-core:$ktor_version"
            }
        }
        commonTest {
            dependencies {
                implementation kotlin('test-common')
                implementation kotlin('test-annotations-common')
            }
        }
        iosX64Main {
            kotlin.srcDirs += 'src/iosMain'
        }
        iosX64Test {
            kotlin.srcDirs += 'src/iosTest'
        }
        iosArm64Main {
            kotlin.srcDirs += 'src/iosMain'
        }
        iosArm64Test {
            kotlin.srcDirs += 'src/iosTest'
        }
        configure([iosX64Main, iosArm64Main]) {
            dependencies {
                implementation "io.ktor:ktor-client-ios:$ktor_version"
            }
        }
        androidMain {
            dependencies {
                implementation kotlin('stdlib-jdk8')
            }
        }
        androidTest {
            dependencies {
                implementation 'junit:junit:4.12'
                implementation 'org.jetbrains.kotlin:kotlin-test'
                implementation 'org.jetbrains.kotlin:kotlin-test-junit'
            }
        }
        configure([androidMain, androidTest]) {
            dependencies {
                implementation "io.ktor:ktor-client-android:$ktor_version"
            }
        }
    }
@Riccardo Montagnin Take a look at how I’m using the
configure
block here, hope that helps.
g
This is a workaround, but it shouldn’t work like that
r
@nestserau Yeah that worked
@gildor Where should I report it?
g
Kotlin issue tracker
l
d
I'm not sure about it being a bug and all, but I think you might want to consider using
api
instead of
implementation
.
I don't think you should be depending on the "internal" dependencies of your dependencies.
g
But this is how main/test dependencies work
Test source set have special relationship with main, for example you have access to internal members and dependencies, this is how it works by default for Java and Kotlin projects and for Android projects without MPP
d
Ah I forgot about that.
r
Also I've reported an
internal
bug that I've encountered: https://youtrack.jetbrains.com/issue/KT-30273
r
The first bug is already reported at https://youtrack.jetbrains.com/issue/KT-29343
r
Thanks, commented mine telling it's a duplicate