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

Riccardo Montagnin

02/28/2019, 9:36 AM
Is it possibile, inside
targets
, to place an
android
clause including a sibling module that is an android app? I have the current structure:
Copy code
project 
   |- android-app
   |- common
        |- commonMain
        |- iosMain
        |- jvmMain
I would like to create some
actual
implementations inside the
android-app
module, which is an Android application module. How would I have to do? Right now when I compile the Android app the
jvmMain
is compiled, but I would like to provide some custom
actual
implementations for the Android app
s

Sabrina Namur

02/28/2019, 9:41 AM
As far as i know it is not possible to use expect/acual between two modules. But i think you can add a addition target 'android' inside your common module and compile it like you do it with your jvmMain.
r

ribesg

02/28/2019, 9:52 AM
You should merge your android project and your mpp project. I have a single
build.gradle.kts
Copy code
project 
    |- commonMain
    |- androidMain
    |- iosMain
    |- jvmMain
r

Riccardo Montagnin

02/28/2019, 9:58 AM
Mmm ok, I'll try that as I'm currently setting up everything from scratch
g

gildor

02/28/2019, 9:59 AM
It actually depends on your use case
if your MPP is library used by multiple platforms, it’s fine to keep Android app separately, but if your project is a multiplatfrom application, than I don’t see why would Android app should be separated
r

Riccardo Montagnin

02/28/2019, 10:01 AM
It will actually be an application, yeah. I want to create an Android, iOS and desktop application that shares the same code between all of them
The desktop app will be made using Java, but with different implementations than the Android version. That's why I'd like to have a
commonMain
, an
iosMain
a
jvmMain
and an
androidMain
g

gildor

02/28/2019, 10:07 AM
yes, it make sense
r

Riccardo Montagnin

02/28/2019, 10:10 AM
Should I go with one module or multi modules?
g

gildor

02/28/2019, 11:34 AM
Multi modules? Depends on your architecture. This supported by mpp
r

ribesg

02/28/2019, 11:36 AM
I guess it’s a matter of preference, I prefer to have a single build file, but I understand that one could need to split some things, especially in the case of mobile apps with tons of flavors
h

h0tk3y

02/28/2019, 11:46 AM
By the way, even with one module, one can still split the build logic by moving parts of the main script into
*.gradle
or
*.gradle.kts
script plugins and applying them in the main build script.
r

ribesg

02/28/2019, 11:47 AM
That’s right, if you need an example of that I think Ktor uses that a lot in its build
r

Riccardo Montagnin

02/28/2019, 11:48 AM
Thank you all guys
u

uli

02/28/2019, 9:21 PM
Is it possible to have one more source set, common to Android and jvm? For things that are the same on both platforms but different on iOS?
r

ribesg

03/01/2019, 9:00 AM
Yes, just define a new sourceSet and state that both the android sourceSet and the jvm sourceSet depend on it
u

uli

03/01/2019, 9:00 AM
thx
5 Views