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

Marc Knaup

03/01/2019, 12:58 PM
How comes that
commonMain/kotlin
is recognized as a source folder and
androidMain/kotlin
is not? The Gradle view in IntelliJ also doesn't list any Android source sets 😞 https://gist.github.com/fluidsonic/04f7b15c4bc5263cd5f82632697804a4
r

ribesg

03/01/2019, 1:02 PM
The android target is a bit special. You have to configure it with the android gradle plugin. See one example here https://gist.github.com/Ribesg/95a172ceb2177d74cf5b15993d40092e#file-build-gradle-kts-L27-L34
m

Marc Knaup

03/01/2019, 1:11 PM
That helps, thanks! The folder is now correct, but IntelliJ still refuses to list the source set 🤔
r

ribesg

03/01/2019, 1:13 PM
Well I don’t have the right icon but everything works and the contained
kotlin
folder is automatically marked as a source directory, so it’s enough for me
m

Marc Knaup

03/01/2019, 1:15 PM
nope, file isn't checked for errors and source set isn't listed 😕
r

ribesg

03/01/2019, 1:29 PM
The gist I linked is what I have and I have no problems. The sourceSet doesn’t show up in the Gradle tab either, but who cares. I have IDE support in it anyway.
m

Marc Knaup

03/01/2019, 1:38 PM
Looks like that Android Studio is doing some non-Gradle magic here because it works there but not in IntelliJ 🙄
k

Kris Wong

03/01/2019, 1:55 PM
well, AS does utilize the android gradle plugin, so that's not entirely surprising
m

Marc Knaup

03/01/2019, 1:56 PM
I wonder if there is a way to force the Source Set to become visible to IntelliJ 🤔
k

Kris Wong

03/01/2019, 1:58 PM
i had some other funny business when building with intellij at first. I had to check a box to force it to delegate to gradle in Preferences
m

Marc Knaup

03/01/2019, 2:02 PM
Copy code
val sourceSetToCompilationData = LinkedHashMap<KotlinSourceSet, MutableSet<GradleSourceSetData>>()
for (target in mppModel.targets) {
    if (target.platform == KotlinPlatform.ANDROID) continue
ugh!
r

ribesg

03/01/2019, 2:04 PM
I’m not using AS.
m

Marc Knaup

03/01/2019, 2:06 PM
I wonder what the difference is which causes that 😞 https://gist.github.com/fluidsonic/04f7b15c4bc5263cd5f82632697804a4
r

ribesg

03/01/2019, 2:23 PM
androidMain
already depends on
commonMain
👌 1
You can also try to completely delete your IDEA project and reimport your Gradle project
m

Marc Knaup

03/01/2019, 2:24 PM
tried already, didn't help though 😕
r

ribesg

03/01/2019, 2:26 PM
I’m also using Gradle 5.2.1 and Android Gradle Plugin 3.2.1 because more recent versions of both are bugged
m

Marc Knaup

03/01/2019, 2:26 PM
Yeah I saw that and tried 3.2.1 too. doesn't help either
r

ribesg

03/01/2019, 2:26 PM
After rollbacking the android gradle plugin you need to clean your project (remove
.gradle
and
build
folders then invalidate cache and restart)
Sorry, I meant Gradle 5.1.1, 5.2.1 is the buggy one
m

Marc Knaup

03/01/2019, 2:27 PM
😵 I guess I'll just start over later today and check if that helps.
2 Views