GitPortal question .... My KMP repo (an existing ...
# touchlab-tools
b
GitPortal question .... My KMP repo (an existing project/library that I'm moving over to gitportal) has several modules, and uses some gradle plugins that aren't otherwise used in the android app. In the KMP repo, the plugins are implemented in the "standard" fashion. That is, they are listed in the root build.grade.kts file with a version and
apply false
, and then listed in each module without a version. When I link the kmp repo with my android app using gitportal, this breaks, because those plugins are not listed in my app project's root build.gradle.kts. So when I try to sync the project, it can't determine the version and fails. The easy solution is to just add those plugins to my android app's root build.gradle.kts. Is that the right way to go about it?
k
With Gradle, there are different ways to configure things, obviously. I'm not sure what would be the "right" way to do anything. However, in the sample/template repos, the included KMP code is added in the Android app's
settings.gradle.kts
file by pointing the module's
projectDir
property to the folder where those modules live.
Copy code
include(":app", ":breeds", ":analytics")
project(":breeds").projectDir = File("library/breeds")
project(":analytics").projectDir = File("library/analytics")
Then the
apply false
Gradle plugins are listed in the root
build.gradle.kts
file.
Copy code
kotlin("multiplatform") version libs.versions.kotlin.get() apply false
    kotlin("plugin.serialization") version libs.versions.kotlin.get() apply false
    id("com.android.library") version kmpLibs.versions.android.gradle.plugin.get() apply false
    alias(libs.plugins.compose.compiler) apply false
To cut down on duplicate versions, I import the KMP repo's version catalog so versions can be derived from either.
Copy code
dependencyResolutionManagement {
    versionCatalogs {
        create("kmpLibs") {
            from(files("library/gradle/libs.versions.toml"))
        }
    }
}
That's a personal preference thing.
I didn't add this next thing to the sample, as I was trying to limit how many things needed explaining, but you can disable ios in KMP when building for Android, and vice-versa. Add a gradle property and override it in the Android repo's
gradle.properties