Skip to content

Commit

Permalink
Introduce Logger Pluggin
Browse files Browse the repository at this point in the history
  • Loading branch information
pablichjenkov committed Oct 11, 2024
1 parent a08b456 commit bdcbe9f
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 4 deletions.
12 changes: 12 additions & 0 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ plugins {
version = "1.0.0"
val themeFlavorProvider = extra["ThemeFlavorProvider"] as String
val authPluginFlavorProvider = extra["AuthPluginFlavorProvider"] as String
val loggerPluginProvider = extra["LoggerPluginProvider"] as String

kotlin {

Expand Down Expand Up @@ -102,6 +103,17 @@ kotlin {
implementation(project(":flavor-theme-a"))
}
}

// Decide which Logger to use based on a build environment variable
when (loggerPluginProvider) {
"Development" -> {
implementation(project(":logger-dev"))
}

"Production" -> {
implementation(project(":logger-prod"))
}
}
}
commonTest.dependencies {
implementation(kotlin("test"))
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ mavenCentral.pass=fake-maven-pass
# Flavors
ThemeFlavorProvider=A
AuthPluginFlavorProvider=Firebase
LoggerPluginProvider=Development
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ kotlin = "2.0.20"
agp = "8.1.4"
composeAndroidCompiler = "1.6.7"
composePlugin = "1.6.10"
androidxActivityCompose = "1.9.0"
androidxActivityCompose = "1.9.2"
kamelImage = "0.9.4"
kotlinxCoroutines = "1.8.1"
ktor = "2.3.11"
Expand Down
68 changes: 68 additions & 0 deletions logger-dev/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.compose)
alias(libs.plugins.android.library)
}

kotlin {
androidTarget()

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "Logger"
isStatic = true
}
}

js(IR) {
browser()
}

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
moduleName = "Logger"
browser()
binaries.library()
}

jvm()

sourceSets {
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.material3)
}
commonTest.dependencies {
}
androidMain.dependencies {
}
jvmMain.dependencies {
}
jsMain.dependencies {
}
}
}

android {
namespace = "com.macaosoftware.plugin.logger"
compileSdk = libs.versions.androidCompileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.androidMinSdk.get().toInt()
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
composeCompiler {
enableStrongSkippingMode = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.macaosoftware.plugin.logger

interface Logger {
fun log(text: String)
}
68 changes: 68 additions & 0 deletions logger-prod/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.compose)
alias(libs.plugins.android.library)
}

kotlin {
androidTarget()

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "Logger"
isStatic = true
}
}

js(IR) {
browser()
}

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
moduleName = "Logger"
browser()
binaries.library()
}

jvm()

sourceSets {
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.material3)
}
commonTest.dependencies {
}
androidMain.dependencies {
}
jvmMain.dependencies {
}
jsMain.dependencies {
}
}
}

android {
namespace = "com.macaosoftware.plugin.logger"
compileSdk = libs.versions.androidCompileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.androidMinSdk.get().toInt()
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
composeCompiler {
enableStrongSkippingMode = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.macaosoftware.plugin.logger

interface Logger {
fun log(text: String)
}
14 changes: 13 additions & 1 deletion macao-sdk-koin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ group = "io.github.pablichjenkov"
version = libs.versions.macaoComponentToolkit.get()
val mavenCentralUser = (findProperty("mavenCentral.user") as? String).orEmpty()
val mavenCentralPass = (findProperty("mavenCentral.pass") as? String).orEmpty()
val loggerPluginProvider = extra["LoggerPluginProvider"] as String

// Configure Dokka
tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
Expand Down Expand Up @@ -98,7 +99,7 @@ kotlin {
androidTarget {
publishLibraryVariants("release", "debug")
}

listOf(
iosX64(),
iosArm64(),
Expand Down Expand Up @@ -136,6 +137,17 @@ kotlin {
// Koin
// api("io.insert-koin:koin-core:3.5.3")
api(libs.koin.core)

// Logger
when (loggerPluginProvider) {
"Development" -> {
implementation(project(":logger-dev"))
}

"Production" -> {
implementation(project(":logger-prod"))
}
}
}
commonTest.dependencies {
// implementation(libs.kotlin.test)
Expand Down
11 changes: 9 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
rootProject.name = "macao-sdui-app"
include(":flavor-theme-a")
include(":flavor-theme-b")

include(":macao-sdk-koin")
include(":composeApp")

// Theme Plugin implementations
include(":flavor-theme-a")
include(":flavor-theme-b")

// Auth Plugin implementations
include(":auth-firebase")
include(":auth-supabase")

// Logger Plugin implementations
include(":logger-dev")
include(":logger-prod")

pluginManagement {
repositories {
google()
Expand Down

0 comments on commit bdcbe9f

Please sign in to comment.