Skip to content

Instantly share code, notes, and snippets.

@Alex009
Last active October 27, 2023 11:06
Show Gist options
  • Save Alex009/a0e4a8af06d063fca78fa48ae440f66f to your computer and use it in GitHub Desktop.
Save Alex009/a0e4a8af06d063fca78fa48ae440f66f to your computer and use it in GitHub Desktop.
valid config of moko-resources with kotlin 1.9.10, compose 1.5.3
/*
* Copyright 2023 LLC Campus.
*/
plugins {
// this is necessary to avoid the plugins to be loaded multiple times
// in each subproject's classloader
kotlin("multiplatform").apply(false)
kotlin("plugin.serialization").apply(false)
id("com.android.application").apply(false)
id("com.android.library").apply(false)
id("org.jetbrains.compose").apply(false)
id("dev.icerock.mobile.multiplatform-resources").apply(false)
}
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#Gradle
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
#Kotlin
kotlin.code.style=official
#MPP
kotlin.mpp.stability.nowarn=true
kotlin.mpp.enableCInteropCommonization=true
kotlin.mpp.androidSourceSetLayoutVersion=2
#Compose
org.jetbrains.compose.experimental.uikit.enabled=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
#Android
android.useAndroidX=true
android.compileSdk=34
android.targetSdk=34
android.minSdk=21
#Versions
kotlin.version=1.9.10
agp.version=8.0.2
compose.version=1.5.3
moko.resources.version=0.23.0
moko.mvvm.version=0.16.1
ktor.version=2.3.0
logback.version=1.2.11
/*
* Copyright 2023 LLC Campus.
*/
import dev.icerock.gradle.tasks.GenerateMultiplatformResourcesTask
import org.jetbrains.kotlin.gradle.tasks.DummyFrameworkTask
plugins {
id("com.android.library")
kotlin("multiplatform")
kotlin("native.cocoapods")
kotlin("plugin.serialization")
id("org.jetbrains.compose")
id("dev.icerock.mobile.multiplatform-resources")
`maven-publish`
}
group = "ru.edclub.learning"
kotlin {
android {
publishLibraryVariantsGroupedByFlavor = true
publishAllLibraryVariants()
}
jvm("desktop")
iosX64()
iosArm64()
iosSimulatorArm64()
js(IR) {
browser {
commonWebpackConfig {}
}
}
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
ios.deploymentTarget = "14.1"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "shared"
isStatic = true
}
extraSpecAttributes["resource"] = "'build/cocoapods/framework/shared.framework/*.bundle'"
}
sourceSets {
val mokoResourcesVersion = extra["moko.resources.version"] as String
val mokoMvvmVersion = extra["moko.mvvm.version"] as String
val ktorVersion = extra["ktor.version"] as String
val commonMain by getting {
dependencies {
implementation(project(":api-model"))
api(project(":navigation"))
implementation(project(":composeui"))
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
api("dev.icerock.moko:resources:$mokoResourcesVersion")
api("dev.icerock.moko:resources-compose:$mokoResourcesVersion")
api("dev.icerock.moko:mvvm-compose:$mokoMvvmVersion")
api("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.5")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
api("io.github.qdsfdhvh:image-loader:1.4.0")
api("io.insert-koin:koin-core:3.4.0")
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-logging:$ktorVersion")
api("io.github.aakira:napier:2.6.1")
// fix of Could not find "shared/build/kotlinTransformedMetadataLibraries/commonMain/org.jetbrains.kotlinx-atomicfu-0.17.3-nativeInterop-8G5yng.klib"
implementation("org.jetbrains.kotlinx:atomicfu:0.19.0")
}
}
val mobileMain by creating {
dependsOn(commonMain)
dependencies {
api("dev.icerock.moko:errors:0.7.0")
implementation("dev.icerock.moko:network:0.21.0")
implementation("dev.icerock.moko:network-engine:0.21.0")
implementation("dev.icerock.moko:network-errors:0.21.0")
}
}
val composeNavigationMain by creating {
dependsOn(commonMain)
}
val androidMain by getting {
dependsOn(mobileMain)
dependsOn(composeNavigationMain)
dependencies {
api("androidx.activity:activity-compose:1.6.1")
api("androidx.appcompat:appcompat:1.6.1")
api("androidx.core:core-ktx:1.9.0")
api("io.insert-koin:koin-android:3.4.0")
implementation("androidx.browser:browser:1.5.0")
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
}
}
val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(mobileMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
}
val desktopMain by getting {
dependsOn(composeNavigationMain)
dependencies {
implementation(compose.desktop.common)
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
}
}
val jsMain by getting {
dependsOn(composeNavigationMain)
}
}
}
multiplatformResources {
multiplatformResourcesPackage = "ru.edclub.learning"
}
android {
compileSdk = (findProperty("android.compileSdk") as String).toInt()
namespace = "ru.edclub.learning.common"
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
defaultConfig {
minSdk = (findProperty("android.minSdk") as String).toInt()
targetSdk = (findProperty("android.targetSdk") as String).toInt()
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlin {
jvmToolchain(11)
}
}
tasks.withType<DummyFrameworkTask>().configureEach {
@Suppress("ObjectLiteralToLambda")
doLast(object : Action<Task> {
override fun execute(task: Task) {
task as DummyFrameworkTask
val frameworkDir = File(task.destinationDir, task.frameworkName.get() + ".framework")
listOf(
"ru.edclub.learning:shared.bundle",
"dev.icerock.moko:errors.bundle",
"dev.icerock.moko:network-errors.bundle",
).forEach { bundleName ->
val bundleDir = File(frameworkDir, bundleName)
bundleDir.mkdir()
File(bundleDir, "dummyFile").writeText("dummy")
}
}
})
}
val generateSourcesTasks = tasks.withType<GenerateMultiplatformResourcesTask>()
tasks.matching { it.name.endsWith("SourcesJar", ignoreCase = true) }
.configureEach {
dependsOn(generateSourcesTasks)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment