kevindmoore
08/17/2021, 7:16 PMKirill Grouchnikov
08/17/2021, 7:23 PMkevindmoore
08/17/2021, 7:27 PMColton Idle
08/17/2021, 7:40 PMkevindmoore
08/17/2021, 7:44 PMkevindmoore
08/17/2021, 7:44 PMColton Idle
08/17/2021, 7:50 PMimplementation(project(":common-composables"))
Colton Idle
08/17/2021, 7:51 PMimport org.jetbrains.compose.compose
plugins {
id("com.android.library")
kotlin("multiplatform")
id("org.jetbrains.compose")
}
kotlin {
android()
jvm("desktop")
sourceSets {
named("commonMain") {
dependencies {
api(compose.runtime)
api(compose.foundation)
api(compose.animation)
api(compose.ui)
api(compose.uiTooling)
api(compose.material)
api(compose.materialIconsExtended)
implementation(compose("org.jetbrains.compose.ui:ui-util"))
}
}
named("androidMain") {
dependencies {
// Compose helpers
implementation("com.google.accompanist:accompanist-insets:0.16.1")
implementation("com.google.accompanist:accompanist-pager:0.16.1")
implementation("com.google.accompanist:accompanist-pager-indicators:0.16.1")
}
}
}
}
android {
compileSdk = 30
defaultConfig {
minSdk = 24
targetSdk = 30
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("<http://consumer-rules.pro|consumer-rules.pro>")
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "<http://proguard-rules.pro|proguard-rules.pro>")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
sourceSets {
named("main") {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
res.srcDirs("src/androidMain/res")
}
}
}
Colton Idle
08/17/2021, 7:53 PMclasspath("com.android.tools.build:gradle:7.1.0-alpha08") //AGP
classpath(kotlin("gradle-plugin", version = "1.5.21")) //KOTLIN
classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha3") //JB COMPOSE
Colton Idle
08/17/2021, 7:53 PMimport org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
kotlin("multiplatform") // kotlin("jvm") doesn't work well in IDEA/AndroidStudio
// (<https://github.com/JetBrains/compose-jb/issues/22>)
id("org.jetbrains.compose")
}
kotlin {
jvm { withJava() }
sourceSets {
named("jvmMain") {
dependencies {
implementation(compose.desktop.currentOs)
implementation(project(":common-composables"))
}
}
}
}
compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "KotlinMultiplatformComposeDesktopApplication"
packageVersion = "1.0.0"
}
}
}
Colton Idle
08/17/2021, 7:54 PMkevindmoore
08/17/2021, 7:59 PM1. Why jvm { withJava() }
kevindmoore
08/17/2021, 7:59 PMkevindmoore
08/17/2021, 8:00 PMColton Idle
08/17/2021, 8:12 PMkevindmoore
08/17/2021, 8:19 PMAndre Classen
08/17/2021, 8:56 PMColton Idle
08/17/2021, 9:00 PMkevindmoore
08/17/2021, 9:43 PMColton Idle
08/18/2021, 12:35 AMIgor Demin
08/18/2021, 6:18 AMWhy jvm { withJava() }Not sure yet, but probably it isn't needed, if your code doesn't have
java
files.
It seems that jvm ("desktop") does something specialYes, this line defines jvm target with a name
desktop
. Without it, Gradle don't know that it needs to compile sources in desktopMain
folder
think there are some pre-defined source set names that are important:For MPP project there is only one predefined source set - commonMain, the other ones you define explicitly:
android() // define android target, main source set is androidMain, test source set is androidTest, instrumental test source set is androidAndroidTest :)
jvm("desktop") // define jvm target, main source set is desktopMain, test source set is desktopTest
Colton Idle
08/18/2021, 8:03 AMAlexey Glushkov
08/18/2021, 7:45 PMkevindmoore
08/18/2021, 9:13 PMjvm { useJava() }