https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
g

GarouDan

11/13/2018, 7:22 PM
Hi guys, If we would like to have the common source sets with different names, how could we do it? Is there something that we can put in our build.gradle? For example
Copy code
commonMain,
commonTest,
jvmMain,
jvmTest,
jsMain,
jsTest
to
Copy code
main,
test,
jvmMain,
jvmTest,
jsMain,
jsTest
h

h0tk3y

11/14/2018, 6:19 PM
In the first place, the names
main
and
test
were not used because of naming (and semantic) conflicts with the Android & Java source sets and variants of the same name. If you don't target Android, you can actually do it by just adding your custom source sets and making
commonMain
and
commonTest
depend on them:
Copy code
kotlin {
    sourceSets {
        main {  }
        test { }
        commonMain.dependsOn main
        commonTest.dependsOn test
    }
}
If you would just like to put the sources in the
src/main
and
src/test
directories, you can instead add those to the
commonMain
and
commonTest
source sets by putting this in `kotlin { sourceSets { ... } }`:
Copy code
commonMain {
    kotlin.srcDirs 'src/main/kotlin`
    resources.srcDir 'src/main/resources'
}
Currently, the
commonMain
and
commonTest
source sets are created unconditionally by
kotlin-multiplatform
, there seems to be no other way to affect that and achieve what you want.
g

GarouDan

11/16/2018, 12:26 PM
Thanks 😃