Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Road to KMP 🚀 #20

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies {
implementation(libs.vespene)
implementation(libs.android.gradle.plugin)
implementation(libs.kotlin.gradle.plugin)
implementation(libs.kotlin.serialization.plugin)
}

gradlePlugin {
Expand All @@ -21,10 +22,18 @@ gradlePlugin {
id = "io.openfeedback.plugins.lib"
implementationClass = "io.openfeedback.plugins.LibraryPlugin"
}
register("io.openfeedback.plugins.lib.multiplatform") {
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"
}
register("io.openfeedback.plugins.app") {
id = "io.openfeedback.plugins.app"
implementationClass = "io.openfeedback.plugins.AppPlugin"
Expand Down
4 changes: 0 additions & 4 deletions build-logic/src/main/kotlin/io/openfeedback/OpenFeedback.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package io.openfeedback

import com.android.build.gradle.internal.tasks.factory.dependsOn
import io.openfeedback.extensions.*
import io.openfeedback.extensions.configurePublishingInternal
import org.gradle.api.Project
import org.gradle.api.logging.LogLevel
import org.gradle.api.tasks.PathSensitivity

open class OpenFeedback(val project: Project) {
fun Project.configurePublishing(artifactName: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ 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.api.plugins.ExtensionAware
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions

internal fun CommonExtension<*, *, *, *, *>.configureKotlinAndroid() {
compileSdk = 34
Expand All @@ -22,10 +20,6 @@ internal fun CommonExtension<*, *, *, *, *>.configureKotlinAndroid() {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
}

internal fun CommonExtension<*, *, *, *, *>.configureAndroidCompose(project: Project) {
Expand All @@ -44,7 +38,3 @@ internal fun CommonExtension<*, *, *, *, *>.configureAndroidCompose(project: Pro
add("debugImplementation", "androidx.savedstate:savedstate-ktx:1.2.0")
}
}

private fun CommonExtension<*, *, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) {
(this as ExtensionAware).extensions.configure("kotlinOptions", block)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.openfeedback.plugins

import com.android.build.gradle.LibraryExtension
import io.openfeedback.OpenFeedback
import io.openfeedback.extensions.configureAndroidCompose
import io.openfeedback.extensions.configureKotlinAndroid
import io.openfeedback.extensions.configureKotlinCompiler
Expand All @@ -14,11 +13,8 @@ class ComposeLibraryPlugin : Plugin<Project> {
with(target.pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.android")
apply("maven-publish")
apply("signing")
}

target.extensions.create("openfeedback", OpenFeedback::class.java, target)
target.extensions.configure<LibraryExtension> {
configureKotlinAndroid()
configureAndroidCompose(target)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.openfeedback.plugins

import com.android.build.gradle.LibraryExtension
import io.openfeedback.OpenFeedback
import io.openfeedback.extensions.configureKotlinAndroid
import io.openfeedback.extensions.configureKotlinCompiler
import org.gradle.api.Plugin
Expand All @@ -13,11 +12,9 @@ class LibraryPlugin : Plugin<Project> {
with(target.pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.android")
apply("maven-publish")
apply("signing")
apply("org.jetbrains.kotlin.plugin.serialization")
}

target.extensions.create("openfeedback", OpenFeedback::class.java, target)
target.extensions.configure<LibraryExtension> {
configureKotlinAndroid()
defaultConfig.targetSdk = 34
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.openfeedback.plugins

import com.android.build.gradle.LibraryExtension
import io.openfeedback.extensions.configureKotlinAndroid
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure

class MultiplatformPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target.pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.multiplatform")
apply("org.jetbrains.kotlin.plugin.serialization")
}

target.extensions.configure<LibraryExtension> {
configureKotlinAndroid()
defaultConfig.targetSdk = 34
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.openfeedback.plugins

import io.openfeedback.OpenFeedback
import org.gradle.api.Plugin
import org.gradle.api.Project

class PublishingPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target.pluginManager) {
apply("maven-publish")
apply("signing")
}
target.extensions.create("openfeedback", OpenFeedback::class.java, target)
}
}
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import io.openfeedback.extensions.configureRoot

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

version = "0.1.1"
subprojects {
allprojects {
repositories {
google()
mavenCentral()
Expand Down
30 changes: 21 additions & 9 deletions libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@
[versions]
kotlin_lang = "1.9.10"
kotlin_coroutines = "1.7.3"
kotlinx_datetime = "0.4.1"
kotlinx_serialization = "1.6.0"
androidx_core = "1.12.0"
androidx_compose_bom = "2023.10.01"
androidx_compose_compiler = "1.5.3"
androidx_lifecycle = "2.6.2"
androidx_savedstate = "1.2.1"
firebase_firestore = "24.0.1"
firebase_auth = "21.0.1"
firebase_common = "20.4.2"
firebase_firestore = "24.9.1"
firebase_auth = "22.3.0"
gitlive_firebase = "1.10.4"
moko_resources = "0.23.0"

[libraries]
android-gradle-plugin = "com.android.tools.build:gradle:8.1.2"
vespene = "net.mbonnin.vespene:vespene-lib:0.5"

kotlin_gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin_lang" }
kotlin_serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin_lang" }
kotlin-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin_coroutines" }
kotlin-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlin_coroutines" }
kotlin-coroutines-play-services = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-play-services", version.ref = "kotlin_coroutines" }

kotlinx_datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx_datetime" }
kotlinx_serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx_serialization" }

firebase_common = { module = "com.google.firebase:firebase-common", version.ref = "firebase_common" }
firebase_firestore = { module = "com.google.firebase:firebase-firestore-ktx", version.ref = "firebase_firestore" }
firebase_auth = { module = "com.google.firebase:firebase-auth", version.ref = "firebase_auth" }
gitlive_app = { module = "dev.gitlive:firebase-app", version.ref = "gitlive_firebase" }
gitlive_firestore = { module = "dev.gitlive:firebase-firestore", version.ref = "gitlive_firebase" }
gitlive_auth = { module = "dev.gitlive:firebase-auth", version.ref = "gitlive_firebase" }
gitlive_common = { module = "dev.gitlive:firebase-common", version.ref = "gitlive_firebase" }

androidx_core = { module = "androidx.core:core-ktx", version.ref = "androidx_core" }
androidx_savedstate = { module = "androidx.savedstate:savedstate-ktx", version.ref = "androidx_savedstate" }
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_foundation = { module = "androidx.compose.foundation:foundation" }
androidx_compose_uitooling = { module = "androidx.compose.ui:ui-tooling" }
androidx_lifecycle_viewmodel_compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx_lifecycle" }
androidx_lifecycle_runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidx_lifecycle" }
androidx_lifecycle_viewmodel_ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", 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" }
1 change: 1 addition & 0 deletions openfeedback-m2/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

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

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.openfeedback.android.R as ROF
import io.openfeedback.R as ROF

@Composable
fun PoweredBy(
Expand Down
2 changes: 2 additions & 0 deletions openfeedback-m3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

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

android {
Expand All @@ -14,6 +15,7 @@ openfeedback {
dependencies {
api(projects.openfeedback)
api(projects.openfeedbackViewmodel)

implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.material3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.openfeedback.android.R
import io.openfeedback.R
import io.openfeedback.android.viewmodels.models.UIComment
import io.openfeedback.android.viewmodels.models.UIDot

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.tooling.preview.Preview
import io.openfeedback.android.R
import io.openfeedback.R

@Composable
fun CommentInput(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.openfeedback.android.R
import io.openfeedback.android.viewmodels.models.UIComment
import io.openfeedback.android.viewmodels.models.UIDot
import io.openfeedback.R

@Composable
internal fun CommentItems(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import io.openfeedback.android.R as ROF
import io.openfeedback.R as ROF

@Composable
internal fun PoweredBy(
Expand Down
1 change: 1 addition & 0 deletions openfeedback-viewmodel/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

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

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package io.openfeedback.android.viewmodels
import android.content.Context
import com.google.firebase.FirebaseApp
import com.google.firebase.FirebaseOptions
import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.initialize

internal object FirebaseFactory {
fun create(
Expand All @@ -18,4 +20,21 @@ internal object FirebaseFactory {
.build()
return FirebaseApp.initializeApp(context, options, appName)
}

fun createKM(
context: Context,
config: OpenFeedbackFirebaseConfig,
appName: String = "openfeedback"
): dev.gitlive.firebase.FirebaseApp {
return Firebase.initialize(
context = context,
options = dev.gitlive.firebase.FirebaseOptions(
projectId = config.projectId,
applicationId = config.applicationId,
apiKey = config.apiKey,
databaseUrl = config.databaseUrl
),
name = appName
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ data class OpenFeedbackFirebaseConfig(
val databaseUrl: String,
val appName: String = "openfeedback"
) {
val firebaseApp = lazy { FirebaseFactory.create(context, this, appName) }
val firebaseApp = lazy { FirebaseFactory.createKM(context, this, appName) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package io.openfeedback.android.viewmodels
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewModelScope
import com.google.firebase.FirebaseApp
import io.openfeedback.android.OpenFeedbackRepository
import io.openfeedback.android.caches.OptimisticVoteCaching
import io.openfeedback.android.model.VoteStatus
import io.openfeedback.android.sources.OpenFeedbackAuth
import io.openfeedback.android.sources.OpenFeedbackFirestore
import dev.gitlive.firebase.FirebaseApp
import io.openfeedback.OpenFeedbackRepository
import io.openfeedback.caches.OptimisticVoteCaching
import io.openfeedback.model.VoteStatus
import io.openfeedback.sources.OpenFeedbackAuth
import io.openfeedback.sources.OpenFeedbackFirestore
import io.openfeedback.android.viewmodels.mappers.convertToUiSessionFeedback
import io.openfeedback.android.viewmodels.models.UIComment
import io.openfeedback.android.viewmodels.models.UISessionFeedback
Expand All @@ -32,8 +32,8 @@ class OpenFeedbackViewModel(
private val locale: Locale
) : ViewModel() {
private val repository = OpenFeedbackRepository(
auth = OpenFeedbackAuth.Factory.create(firebaseApp),
firestore = OpenFeedbackFirestore.Factory.create(firebaseApp),
auth = OpenFeedbackAuth.create(firebaseApp),
firestore = OpenFeedbackFirestore.create(firebaseApp),
optimisticVoteCaching = OptimisticVoteCaching()
)

Expand Down
Loading
Loading