When opening the composite build project, composed...
# multiplatform
d
When opening the composite build project, composed-in dependencies aren't resolved properly by the IDE (highlighted red), even though the Gradle build can succeed.
‼️ 1
d
Ouch; was hoping it was just me, but there is a cluster of unresolved defects against IDEA platform related to Gradle Composite builds and Multi-Source Set projects (which naturally includes all Kotlin/MP projects): https://youtrack.jetbrains.com/issue/KT-30459 https://youtrack.jetbrains.com/issue/KT-31069 https://youtrack.jetbrains.com/issue/KT-30413 https://youtrack.jetbrains.com/issue/KT-30285 😞 Do consider voting if you use Kotlin/MP - Gradle Composite Build is a super useful feature and it's disturbing to see this combination doesn't work properly.
l
My colleague found 2 workarounds, so we are ok currently.
🤷‍♂️ 1
d
@Larten Can you elaborate on what the workarounds were?
l
In the StackOverflow comment is the first: " For temporary workaround, we created a separate module, which pulls together all the source files into one fat module, but we would really like to keep our modularized mpp project, so this is only a temporary hack." For the second summon @agta1991
a
Hi, yeah I had a hard time with this includeBuild Gradle settings. Till now I couldn't make it to work properly, but I hope there will be some fix it soon. Now I have two workarounds for this, the first one is ugly, pull all the sourcesets into a single MPP module which can be included to the other one. The second is a bit more nicer, without the use of includeBuild you will loose gradle config parts like the included settings.gradle and properties, etc. so all these settigns should be shared between the parent project (maybe a good idea to move them into buildSrc module and share), and if everything is shared, then include the subproject's modules into the parent project (to bypass the includeBuild).
t
Here’s the trick that works for me: 1.
includeBuild
to the mpp project as usual. 2. Let the
preBuild
task of the host module depend on the
assembleDebug
task of the mpp module. The purpose is to generate
aar
file beforehand. 3.
implementation files(path_to_generated_aar_file)
instead of
implementation 'some_group_id:some_lib_name:some_version'
Doing that way the IDE can resolve dependencies by using `.class`s from the aar file. Yet, we still have the ability to jump to definition of classes from the mpp project when debugging. BTW, I use
Android Studio 4.1
,
gradle plugin 4.0.1
, and
gradle 6.5
. Hope it’s helpful.
💯 1
👍 1