From 314f5af47f777f0988f3f4de8dc0d399324d0a47 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Tue, 3 Nov 2020 17:13:56 +0300 Subject: [PATCH] Update all examples with Compose Application DSL --- examples/codeviewer/README.md | 18 +++++++++++---- examples/codeviewer/build.gradle.kts | 4 ++++ examples/codeviewer/desktop/build.gradle.kts | 20 +++++++++++++---- examples/imageviewer/README.md | 16 ++++++++++++-- examples/imageviewer/build.gradle.kts | 1 + examples/issues/README.md | 13 +++++++++-- examples/issues/build.gradle.kts | 2 ++ examples/issues/desktop/build.gradle.kts | 22 ++++++++++++++----- examples/todoapp/README.md | 15 +++++++++++-- examples/todoapp/buildSrc/build.gradle.kts | 4 ++++ examples/todoapp/desktop/build.gradle.kts | 20 +++++++++++++---- templates/desktop-template/README.md | 3 +-- templates/desktop-template/build.gradle.kts | 15 +++++++++---- .../desktop-template/settings.gradle.kts | 2 ++ templates/multiplatform-template/README.md | 3 +-- .../multiplatform-template/build.gradle.kts | 2 ++ .../desktop/build.gradle.kts | 16 +++++++++----- 17 files changed, 140 insertions(+), 36 deletions(-) diff --git a/examples/codeviewer/README.md b/examples/codeviewer/README.md index 364bc6e27a..436a682c77 100644 --- a/examples/codeviewer/README.md +++ b/examples/codeviewer/README.md @@ -1,7 +1,17 @@ MPP Code Viewer example for desktop/android written in Multiplatform Compose library. -To run desktop application execute in a terminal: -`./gradlew desktop:run` +### Running desktop application +``` +./gradlew :desktop:run +``` -To install android application on device/emulator: -'./gradlew installDebug' \ No newline at end of file +### Building native desktop distribution +``` +./gradlew :desktop:package +# outputs are written to desktop/build/compose/binaries +``` + +### Installing Android application on device/emulator +``` +./gradlew installDebug +``` \ No newline at end of file diff --git a/examples/codeviewer/build.gradle.kts b/examples/codeviewer/build.gradle.kts index 5a07e59003..77dc569f53 100644 --- a/examples/codeviewer/build.gradle.kts +++ b/examples/codeviewer/build.gradle.kts @@ -1,5 +1,7 @@ buildscript { repositories { + // TODO: remove after new build is published + mavenLocal() google() jcenter() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") @@ -16,6 +18,8 @@ buildscript { allprojects { repositories { + // TODO: remove after new build is published + mavenLocal() google() jcenter() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") diff --git a/examples/codeviewer/desktop/build.gradle.kts b/examples/codeviewer/desktop/build.gradle.kts index 04fb343839..5f86dc5975 100644 --- a/examples/codeviewer/desktop/build.gradle.kts +++ b/examples/codeviewer/desktop/build.gradle.kts @@ -1,10 +1,9 @@ import 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") - java - application } kotlin { @@ -22,6 +21,19 @@ kotlin { } } -application { - mainClassName = "org.jetbrains.codeviewer.MainKt" +compose.desktop { + application { + mainClass = "org.jetbrains.codeviewer.MainKt" + + nativeDistributions { + targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) + packageName = "ComoseCodeViewer" + + windows { + menu = true + // see https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html + upgradeUuid = "AF792DA6-2EA3-495A-95E5-C3C6CBCB9948" + } + } + } } diff --git a/examples/imageviewer/README.md b/examples/imageviewer/README.md index 090e0d53ab..c28e88befd 100755 --- a/examples/imageviewer/README.md +++ b/examples/imageviewer/README.md @@ -1,4 +1,16 @@ An example of image gallery for remote server image viewing, based on Jetpack Compose UI library (desktop and android). -To run desktop application execute in terminal: ./gradlew desktop:run -To run android application you will need to open project in Intellij IDEA or Android Studio and run "android" configuration +### Running desktop application +``` +./gradlew :desktop:run +``` + +### Building native desktop distribution +``` +./gradlew :desktop:package +# outputs are written to desktop/build/compose/binaries +``` + +### Running Android application + +Open project in Intellij IDEA or Android Studio and run "android" configuration. diff --git a/examples/imageviewer/build.gradle.kts b/examples/imageviewer/build.gradle.kts index 04d672ff92..727a6a6dab 100755 --- a/examples/imageviewer/build.gradle.kts +++ b/examples/imageviewer/build.gradle.kts @@ -1,5 +1,6 @@ buildscript { repositories { + // TODO: remove after new build is published mavenLocal().mavenContent { includeModule("org.jetbrains.compose", "compose-gradle-plugin") } diff --git a/examples/issues/README.md b/examples/issues/README.md index 20cbaad389..82b13ada5f 100644 --- a/examples/issues/README.md +++ b/examples/issues/README.md @@ -1,4 +1,13 @@ Github Issues viewer example written in Jetpack Compose UI library. -To run desktop application execute in terminal: -`./gradlew run` + +### Running desktop application +``` +./gradlew :desktop:run +``` + +### Building native desktop distribution +``` +./gradlew :desktop:package +# outputs are written to desktop/build/compose/binaries +``` diff --git a/examples/issues/build.gradle.kts b/examples/issues/build.gradle.kts index 55b201313a..6967b0a359 100644 --- a/examples/issues/build.gradle.kts +++ b/examples/issues/build.gradle.kts @@ -1,5 +1,7 @@ buildscript { repositories { + // TODO: remove after new build is published + mavenLocal() google() jcenter() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") diff --git a/examples/issues/desktop/build.gradle.kts b/examples/issues/desktop/build.gradle.kts index 4a433dfef8..de5b7567be 100644 --- a/examples/issues/desktop/build.gradle.kts +++ b/examples/issues/desktop/build.gradle.kts @@ -1,10 +1,9 @@ import 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") - java - application } kotlin { @@ -21,6 +20,19 @@ kotlin { } } -application { - mainClassName = "androidx.ui.examples.jetissues.MainKt" -} \ No newline at end of file +compose.desktop { + application { + mainClass = "androidx.ui.examples.jetissues.MainKt" + + nativeDistributions { + targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) + packageName = "IssuesViewer" + + windows { + menu = true + // see https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html + upgradeUuid = "6565BEAD-713A-4DE7-A469-6B10FC4A6861" + } + } + } +} diff --git a/examples/todoapp/README.md b/examples/todoapp/README.md index 93e6e3124b..a996ce0757 100755 --- a/examples/todoapp/README.md +++ b/examples/todoapp/README.md @@ -23,6 +23,17 @@ Features: - View state is preserved when navigating between screens, Android configuration change, etc. - Model-View-Intent (aka MVI) architectural pattern -To run the desktop application execute the following command: `./gradlew desktop:run`. +### Running desktop application +``` +./gradlew :desktop:run +``` -To run the Android application you will need to open the project in Intellij IDEA or Android Studio and run "android" configuration. +### Building native desktop distribution +``` +./gradlew :desktop:package +# outputs are written to desktop/build/compose/binaries +``` + +### Running Android application + +Open project in Intellij IDEA or Android Studio and run "android" configuration. diff --git a/examples/todoapp/buildSrc/build.gradle.kts b/examples/todoapp/buildSrc/build.gradle.kts index 14902d9219..6fd743b688 100644 --- a/examples/todoapp/buildSrc/build.gradle.kts +++ b/examples/todoapp/buildSrc/build.gradle.kts @@ -4,6 +4,8 @@ plugins { } repositories { + // TODO: remove after new build is published + mavenLocal() google() jcenter() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") @@ -11,6 +13,8 @@ repositories { buildscript { repositories { + // TODO: remove after new build is published + mavenLocal() google() jcenter() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") diff --git a/examples/todoapp/desktop/build.gradle.kts b/examples/todoapp/desktop/build.gradle.kts index 0ea31179d7..8d2ebe1944 100755 --- a/examples/todoapp/desktop/build.gradle.kts +++ b/examples/todoapp/desktop/build.gradle.kts @@ -1,10 +1,9 @@ import 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") - java - application } kotlin { @@ -29,6 +28,19 @@ kotlin { } } -application { - mainClassName = "example.todo.desktop.MainKt" +compose.desktop { + application { + mainClass = "example.todo.desktop.MainKt" + + nativeDistributions { + targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) + packageName = "ComoseDesktopTodo" + + windows { + menuGroup = "Compose Examples" + // see https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html + upgradeUuid = "BF9CDA6A-1391-46D5-9ED5-383D6E68CCEB" + } + } + } } diff --git a/templates/desktop-template/README.md b/templates/desktop-template/README.md index d47d754f20..fd40023b91 100644 --- a/templates/desktop-template/README.md +++ b/templates/desktop-template/README.md @@ -1,5 +1,4 @@ Compose Desktop Application - `./gradlew run` - run application -- `./gradlew install` - build application into `build/install` -- `./gradlew distZip` - build and create archive ready for distribution in `build/distributions/desktop.zip` \ No newline at end of file +- `./gradlew package` - package native distribution into `build/compose/binaries` diff --git a/templates/desktop-template/build.gradle.kts b/templates/desktop-template/build.gradle.kts index ffd33fec28..3ee01fb050 100644 --- a/templates/desktop-template/build.gradle.kts +++ b/templates/desktop-template/build.gradle.kts @@ -1,9 +1,9 @@ import org.jetbrains.compose.compose +import org.jetbrains.compose.desktop.application.dsl.TargetFormat plugins { kotlin("jvm") version "1.4.0" id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.1.0-m1-build57") - application } repositories { @@ -15,6 +15,13 @@ dependencies { implementation(compose.desktop.currentOs) } -application { - mainClassName = "MainKt" -} +compose.desktop { + application { + mainClass = "MainKt" + + nativeDistributions { + targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) + packageName = "KotlinJvmComposeDesktopApplication" + } + } +} \ No newline at end of file diff --git a/templates/desktop-template/settings.gradle.kts b/templates/desktop-template/settings.gradle.kts index 781ae9381e..1676142749 100644 --- a/templates/desktop-template/settings.gradle.kts +++ b/templates/desktop-template/settings.gradle.kts @@ -1,5 +1,7 @@ pluginManagement { repositories { + // TODO: remove after new build is published + mavenLocal() gradlePluginPortal() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") } diff --git a/templates/multiplatform-template/README.md b/templates/multiplatform-template/README.md index 33d19a940e..61bee9df8c 100644 --- a/templates/multiplatform-template/README.md +++ b/templates/multiplatform-template/README.md @@ -2,8 +2,7 @@ Compose Multiplatform Application **Desktop** - `./gradlew run` - run application -- `./gradlew install` - build application into `desktop/build/install` -- `./gradlew distZip` - build and create archive ready for distribution in `desktop/build/distributions/desktop.zip` +- `./gradlew package` - package native distribution into `build/compose/binaries` **Android** - `./gradlew installDebug` - install Android application on an Android device (on a real device or on an emulator) \ No newline at end of file diff --git a/templates/multiplatform-template/build.gradle.kts b/templates/multiplatform-template/build.gradle.kts index 506d7603ed..469fb8fb93 100644 --- a/templates/multiplatform-template/build.gradle.kts +++ b/templates/multiplatform-template/build.gradle.kts @@ -2,6 +2,8 @@ buildscript { val composeVersion = System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.1.0-m1-build57" repositories { + // TODO: remove after new build is published + mavenLocal() google() jcenter() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") diff --git a/templates/multiplatform-template/desktop/build.gradle.kts b/templates/multiplatform-template/desktop/build.gradle.kts index eaa9f9e584..f430a77e8d 100644 --- a/templates/multiplatform-template/desktop/build.gradle.kts +++ b/templates/multiplatform-template/desktop/build.gradle.kts @@ -1,10 +1,9 @@ import 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") - java - application } kotlin { @@ -21,6 +20,13 @@ kotlin { } } -application { - mainClassName = "MainKt" -} +compose.desktop { + application { + mainClass = "MainKt" + + nativeDistributions { + targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) + packageName = "KotlinMultiplatformComposeDesktopApplication" + } + } +} \ No newline at end of file