Skip to content

Commit

Permalink
refactor: migrate Compose to Compose multiplatform.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Nov 24, 2023
1 parent 3187fc3 commit 570f8ad
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 79 deletions.
4 changes: 0 additions & 4 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ gradlePlugin {
id = "io.openfeedback.plugins.lib.multiplatform"
implementationClass = "io.openfeedback.plugins.MultiplatformPlugin"
}
register("io.openfeedback.plugins.compose.lib") {
id = "io.openfeedback.plugins.compose.lib"
implementationClass = "io.openfeedback.plugins.ComposeLibraryPlugin"
}
register("io.openfeedback.plugins.publishing") {
id = "io.openfeedback.plugins.publishing"
implementationClass = "io.openfeedback.plugins.PublishingPlugin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ package io.openfeedback.extensions

import com.android.build.api.dsl.CommonExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType

internal fun CommonExtension<*, *, *, *, *>.configureKotlinAndroid() {
compileSdk = 34
Expand All @@ -21,20 +17,3 @@ internal fun CommonExtension<*, *, *, *, *>.configureKotlinAndroid() {
targetCompatibility = JavaVersion.VERSION_17
}
}

internal fun CommonExtension<*, *, *, *, *>.configureAndroidCompose(project: Project) {
val libs = project.extensions.getByType<VersionCatalogsExtension>().named("libs")

buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = libs.findVersion("androidx_compose_compiler").get().toString()
}

project.dependencies {
add("debugImplementation", "androidx.customview:customview-poolingcontainer:1.0.0")
add("debugImplementation", "androidx.savedstate:savedstate-ktx:1.2.0")
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.openfeedback.plugins

import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
import io.openfeedback.extensions.configureAndroidCompose
import io.openfeedback.extensions.configureKotlinAndroid
import io.openfeedback.extensions.configureKotlinCompiler
import org.gradle.api.Plugin
Expand All @@ -14,10 +13,8 @@ class AppPlugin : Plugin<Project> {
apply("com.android.application")
apply("org.jetbrains.kotlin.android")
}

target.extensions.configure<BaseAppModuleExtension> {
configureKotlinAndroid()
configureAndroidCompose(target)
}
target.tasks.configureKotlinCompiler()
}
Expand Down

This file was deleted.

3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import io.openfeedback.extensions.configureRoot

plugins {
id("io.openfeedback.plugins.compose.lib") apply false
id("io.openfeedback.plugins.lib") apply false
alias(libs.plugins.moko.resources.generator) apply false
alias(libs.plugins.jetbrains.compose) apply false
}

version = "0.1.2"
Expand Down
10 changes: 2 additions & 8 deletions libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ kotlin_lang = "1.9.10"
kotlin_coroutines = "1.7.3"
kotlinx_datetime = "0.4.1"
kotlinx_serialization = "1.6.0"
jetbrains_compose = "1.5.1"
androidx_core = "1.12.0"
androidx_compose_bom = "2023.10.01"
androidx_compose_compiler = "1.5.3"
androidx_lifecycle = "2.6.2"
firebase_common = "20.4.2"
firebase_firestore = "24.9.1"
Expand Down Expand Up @@ -33,15 +32,10 @@ gitlive_auth = { module = "dev.gitlive:firebase-auth", version.ref = "gitlive_fi
gitlive_common = { module = "dev.gitlive:firebase-common", version.ref = "gitlive_firebase" }

androidx_core = { module = "androidx.core:core-ktx", version.ref = "androidx_core" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidx_compose_bom" }
androidx_compose_material = { module = "androidx.compose.material:material" }
androidx_compose_material3 = { module = "androidx.compose.material3:material3" }
androidx_compose_ui = { module = "androidx.compose.ui:ui" }
androidx_compose_runtime = { module = "androidx.compose.runtime:runtime" }
androidx_compose_uitooling = { module = "androidx.compose.ui:ui-tooling" }
androidx_lifecycle_viewmodel_compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx_lifecycle" }

moko_resources = { module = "dev.icerock.moko:resources", version.ref = "moko_resources"}

[plugins]
moko_resources_generator = { id = "dev.icerock.mobile.multiplatform-resources", version.ref = "moko_resources" }
jetbrains_compose = { id = "org.jetbrains.compose", version.ref = "jetbrains_compose" }
11 changes: 6 additions & 5 deletions openfeedback-m2/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

plugins {
id("io.openfeedback.plugins.compose.lib")
id("io.openfeedback.plugins.lib")
id("io.openfeedback.plugins.publishing")
alias(libs.plugins.jetbrains.compose)
}

android {
Expand All @@ -15,9 +16,9 @@ openfeedback {
dependencies {
api(projects.openfeedback)
api(projects.openfeedbackViewmodel)

implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.material)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.uitooling)
implementation(compose.material)
implementation(compose.ui)
implementation(compose.uiTooling)
}
10 changes: 5 additions & 5 deletions openfeedback-m3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

plugins {
id("io.openfeedback.plugins.compose.lib")
id("io.openfeedback.plugins.lib")
id("io.openfeedback.plugins.publishing")
alias(libs.plugins.jetbrains.compose)
}

android {
Expand All @@ -17,8 +18,7 @@ dependencies {
api(projects.openfeedbackViewmodel)

implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.uitooling)
implementation(compose.material3)
implementation(compose.ui)
implementation(compose.uiTooling)
}
8 changes: 4 additions & 4 deletions openfeedback-viewmodel/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

plugins {
id("io.openfeedback.plugins.compose.lib")
id("io.openfeedback.plugins.lib")
id("io.openfeedback.plugins.publishing")
alias(libs.plugins.jetbrains.compose)
}

android {
Expand All @@ -15,6 +15,6 @@ openfeedback {
dependencies {
implementation(projects.openfeedback)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.runtime)
implementation(compose.runtime)

}
6 changes: 3 additions & 3 deletions sample-app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id("io.openfeedback.plugins.app")
alias(libs.plugins.jetbrains.compose)
}

android {
Expand All @@ -15,9 +16,8 @@ dependencies {
implementation("androidx.appcompat:appcompat:1.5.1")
implementation("androidx.activity:activity-compose:1.7.0-alpha02")

implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.material)
implementation(libs.androidx.compose.material3)
implementation(compose.material)
implementation(compose.material3)

implementation(projects.openfeedbackM2)
implementation(projects.openfeedbackM3)
Expand Down

0 comments on commit 570f8ad

Please sign in to comment.