From 7217dbd549b206ef8ef6c28aafc36dd619a8b030 Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Thu, 27 Jan 2022 10:35:36 +0300 Subject: [PATCH] App API WIP --- components/App/demo/build.gradle.kts | 29 ++++++++++++++++ .../org/jetbrains/compose/app/demo/Main.kt | 10 ++++++ components/App/library/build.gradle.kts | 33 +++++++++++++++++++ .../kotlin/org/jetbrains/compose/app/App.kt | 10 ++++++ components/settings.gradle.kts | 5 ++- 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 components/App/demo/build.gradle.kts create mode 100644 components/App/demo/src/jvmMain/kotlin/org/jetbrains/compose/app/demo/Main.kt create mode 100644 components/App/library/build.gradle.kts create mode 100644 components/App/library/src/desktopMain/kotlin/org/jetbrains/compose/app/App.kt diff --git a/components/App/demo/build.gradle.kts b/components/App/demo/build.gradle.kts new file mode 100644 index 0000000000..c3595d23a8 --- /dev/null +++ b/components/App/demo/build.gradle.kts @@ -0,0 +1,29 @@ +import org.jetbrains.compose.compose +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + kotlin("multiplatform") + id("org.jetbrains.compose") +} + +kotlin { + jvm {} + sourceSets { + named("jvmMain") { + dependencies { + implementation(compose.desktop.currentOs) + implementation(project(":App:library")) + } + } + } +} + +compose.desktop { + application { + mainClass = "org.jetbrains.compose.app.demo.MainKt" + } +} + +tasks.withType().configureEach { + kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" +} diff --git a/components/App/demo/src/jvmMain/kotlin/org/jetbrains/compose/app/demo/Main.kt b/components/App/demo/src/jvmMain/kotlin/org/jetbrains/compose/app/demo/Main.kt new file mode 100644 index 0000000000..f5d5554206 --- /dev/null +++ b/components/App/demo/src/jvmMain/kotlin/org/jetbrains/compose/app/demo/Main.kt @@ -0,0 +1,10 @@ +package org.jetbrains.compose.app.demo + +import androidx.compose.material.Text +import org.jetbrains.compose.app.application + +fun main() = application( + title = "App demo" +) { + Text("Hi") +} diff --git a/components/App/library/build.gradle.kts b/components/App/library/build.gradle.kts new file mode 100644 index 0000000000..190b7f83fb --- /dev/null +++ b/components/App/library/build.gradle.kts @@ -0,0 +1,33 @@ +import org.jetbrains.compose.compose +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + kotlin("multiplatform") + id("org.jetbrains.compose") + id("maven-publish") +} + +kotlin { + jvm("desktop") + + sourceSets { + named("commonMain") { + dependencies { + api(compose.runtime) + api(compose.foundation) + api(compose.material) + } + } + named("desktopMain") {} + } +} + +tasks.withType().configureEach { + kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" +} + +configureMavenPublication( + groupId = "org.jetbrains.compose.components", + artifactId = "components-app", + name = "App API for Compose Multiplatform" +) diff --git a/components/App/library/src/desktopMain/kotlin/org/jetbrains/compose/app/App.kt b/components/App/library/src/desktopMain/kotlin/org/jetbrains/compose/app/App.kt new file mode 100644 index 0000000000..4318f55bad --- /dev/null +++ b/components/App/library/src/desktopMain/kotlin/org/jetbrains/compose/app/App.kt @@ -0,0 +1,10 @@ +package org.jetbrains.compose.app + +import androidx.compose.runtime.Composable +import androidx.compose.ui.window.singleWindowApplication + +fun application(name: String = "application", title: String = "Compose Application", body: @Composable () -> Unit) { + singleWindowApplication { + body() + } +} diff --git a/components/settings.gradle.kts b/components/settings.gradle.kts index 4034e8aa4a..d2344460c3 100644 --- a/components/settings.gradle.kts +++ b/components/settings.gradle.kts @@ -14,4 +14,7 @@ pluginManagement { } include(":SplitPane:library") -include(":SplitPane:demo") \ No newline at end of file +include(":SplitPane:demo") + +include(":App:library") +include(":App:demo")