From fd97e9749e763e79cb00defddf96a69444ae5194 Mon Sep 17 00:00:00 2001 From: Cdm2883 Date: Thu, 3 Oct 2024 14:43:04 +0800 Subject: [PATCH] build: compose shared lib --- build.gradle.kts | 2 ++ example/build.gradle.kts | 4 +++- gradle/libs.versions.toml | 3 +++ plugin/compose-lib.gradle.kts | 39 +++++++++++++++++++++++++++++++++++ settings.gradle.kts | 22 +++++++++++++++++++- 5 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 plugin/compose-lib.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts index 7a158d0..447734e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,6 +2,8 @@ plugins { // this is necessary to avoid the plugins to be loaded multiple times // in each subproject's classloader alias(libs.plugins.kotlin.jvm) apply false + alias(libs.plugins.compose.compiler) apply false + alias(libs.plugins.jetbrains.compose) apply false alias(libs.plugins.gradleup.shadow) apply false } diff --git a/example/build.gradle.kts b/example/build.gradle.kts index 35624b4..4e95d34 100644 --- a/example/build.gradle.kts +++ b/example/build.gradle.kts @@ -1,11 +1,13 @@ plugins { alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.compose.compiler) + alias(libs.plugins.jetbrains.compose) alias(libs.plugins.gradleup.shadow) } dependencies { compileOnly(libs.allaymc.api) - compileOnly(projects.plugin) + compileOnly(projects.plugin.composeLib) } kotlin { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4586159..ba68b04 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,6 +3,7 @@ allaymc-kotlinx = "0.1.0-alpha" allaymc-api = "master-SNAPSHOT" kotlin = "2.0.20" +compose-plugin = "1.6.11" gradleup-shadow = "8.3.0" kotlinx-coroutines-core = "1.9.0" @@ -15,4 +16,6 @@ kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines- [plugins] kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +jetbrains-compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" } gradleup-shadow = { id = "com.gradleup.shadow", version.ref = "gradleup-shadow" } diff --git a/plugin/compose-lib.gradle.kts b/plugin/compose-lib.gradle.kts new file mode 100644 index 0000000..2b6b303 --- /dev/null +++ b/plugin/compose-lib.gradle.kts @@ -0,0 +1,39 @@ +import org.jetbrains.compose.ExperimentalComposeLibrary + +plugins { + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.compose.compiler) + alias(libs.plugins.jetbrains.compose) + alias(libs.plugins.gradleup.shadow) +} + +@Suppress("DEPRECATION") +buildDir = file("../build") + +@OptIn(ExperimentalComposeLibrary::class) +dependencies { + api(projects.plugin) + + api(compose.runtime) + api(compose.ui) + api(compose.foundation) + api(compose.material) + api(compose.material3) + api(compose.materialIconsExtended) + api(compose.animation) + api(compose.animationGraphics) + api(compose.runtimeSaveable) + api(compose.components.resources) + api(compose.components.uiToolingPreview) + api(compose.desktop.linux_x64) + api(compose.desktop.linux_arm64) + api(compose.desktop.macos_x64) + api(compose.desktop.macos_arm64) + api(compose.desktop.windows_x64) + api(compose.desktop.components.splitPane) + api(compose.desktop.components.animatedImage) +} + +kotlin { + jvmToolchain(21) +} diff --git a/settings.gradle.kts b/settings.gradle.kts index e2e3e37..33a1ca7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,6 +3,14 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") pluginManagement { repositories { + google { + @Suppress("UnstableApiUsage") + mavenContent { + includeGroupAndSubgroups("androidx") + includeGroupAndSubgroups("com.android") + includeGroupAndSubgroups("com.google") + } + } mavenCentral() gradlePluginPortal() } @@ -11,6 +19,13 @@ pluginManagement { dependencyResolutionManagement { @Suppress("UnstableApiUsage") repositories { + google { + mavenContent { + includeGroupAndSubgroups("androidx") + includeGroupAndSubgroups("com.android") + includeGroupAndSubgroups("com.google") + } + } mavenCentral() maven("https://jitpack.io/") maven("https://www.jitpack.io/") @@ -21,5 +36,10 @@ dependencyResolutionManagement { } include(":core") -include(":plugin") +include(":plugin", ":plugin:compose-lib") +project(":plugin:compose-lib").apply { + buildFileName = "../compose-lib.gradle.kts" + projectDir = file("plugin/build") // set to any existing dir +} + include(":example")