Skip to content

Commit

Permalink
- move BuildConfig generation to domain module + move default networ…
Browse files Browse the repository at this point in the history
…king values into gradle.properties
  • Loading branch information
rodvar committed Dec 10, 2024
1 parent e21cf38 commit 0e688da
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 46 deletions.
23 changes: 15 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
#Gradle
# Gradle
org.gradle.jvmargs=-Xmx8g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx8g"
org.gradle.caching=true
org.gradle.configuration-cache=true

#Kotlin
# Kotlin
kotlin.code.style=official

#Android
# Android
android.useAndroidX=true
android.nonTransitiveRClass=true

#Versioning
shared.version=0.0.9
# Versioning
shared.version=0.0.11

node.name=Bisq
node.android.version=0.0.5
node.android.version=0.0.7

client.name=BisqClient
client.android.version=0.0.3
client.ios.version=0.0.3
client.android.version=0.0.5
client.ios.version=0.0.5

# Networking

## Defaults for connectivity when not set by user
client.x.trustednode.port=8090
client.android.trustednode.ip=10.0.2.2
client.ios.trustednode.ip=localhost
38 changes: 38 additions & 0 deletions shared/domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,49 @@ plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.kotlinCocoapods)
alias(libs.plugins.androidLibrary)
alias(libs.plugins.buildconfig)
kotlin("plugin.serialization") version "2.0.21"
}

version = project.findProperty("shared.version") as String

// NOTE: The following allow us to configure each app type independently and link for example with gradle.properties
// local.properties overrides any property if you need to setup for example local networking
// TODO potentially to be refactored into a shared/common module
buildConfig {
useKotlinOutput { internalVisibility = false }
forClass("network.bisq.mobile.client.shared", className = "BuildConfig") {
buildConfigField("APP_NAME", project.findProperty("client.name").toString())
buildConfigField(
"ANDROID_APP_VERSION",
project.findProperty("client.android.version").toString()
)
buildConfigField("IOS_APP_VERSION", project.findProperty("client.ios.version").toString())
buildConfigField("SHARED_LIBS_VERSION", project.version.toString())
buildConfigField("BUILD_TS", System.currentTimeMillis())
// networking setup
buildConfigField("WS_PORT", project.findProperty("client.x.trustednode.port").toString())
buildConfigField("WS_ANDROID_HOST", project.findProperty("client.android.trustednode.ip").toString())
buildConfigField("WS_IOS_HOST", project.findProperty("client.ios.trustednode.ip").toString())
}
forClass("network.bisq.mobile.android.node", className = "BuildNodeConfig") {
buildConfigField("APP_NAME", project.findProperty("node.name").toString())
buildConfigField("APP_VERSION", project.findProperty("node.android.version").toString())
buildConfigField("SHARED_LIBS_VERSION", project.version.toString())
buildConfigField("BUILD_TS", System.currentTimeMillis())
}
// buildConfigField("APP_SECRET", "Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu")
// buildConfigField<String>("OPTIONAL", null)
// buildConfigField("FEATURE_ENABLED", true)
// buildConfigField("MAGIC_NUMBERS", intArrayOf(1, 2, 3, 4))
// buildConfigField("STRING_LIST", arrayOf("a", "b", "c"))
// buildConfigField("MAP", mapOf("a" to 1, "b" to 2))
// buildConfigField("FILE", File("aFile"))
// buildConfigField("URI", uri("https://example.io"))
// buildConfigField("com.github.gmazzo.buildconfig.demos.kts.SomeData", "DATA", "SomeData(\"a\", 1)")

}

kotlin {
androidTarget {
compilations.all {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import network.bisq.mobile.client.market.ClientMarketPriceServiceFacade
import network.bisq.mobile.client.market.MarketPriceApiGateway
import network.bisq.mobile.client.offerbook.ClientOfferbookServiceFacade
import network.bisq.mobile.client.offerbook.offer.OfferbookApiGateway
import network.bisq.mobile.client.shared.BuildConfig
import network.bisq.mobile.client.websocket.WebSocketClient
import network.bisq.mobile.client.websocket.rest_api_proxy.WebSocketRestApiClient
import network.bisq.mobile.client.websocket.messages.SubscriptionRequest
Expand Down Expand Up @@ -69,9 +70,9 @@ val clientModule = module {
single<ApplicationBootstrapFacade> { ClientApplicationBootstrapFacade() }

single(named("RestApiHost")) { provideRestApiHost() }
single(named("RestApiPort")) { 8090 }
single(named("RestApiPort")) { (BuildConfig.WS_PORT.takeIf { it.isNotEmpty() } ?: "8090").toInt() }
single(named("WebsocketApiHost")) { provideWebsocketHost() }
single(named("WebsocketApiPort")) { 8090 }
single(named("WebsocketApiPort")) { (BuildConfig.WS_PORT.takeIf { it.isNotEmpty() } ?: "8090").toInt() }

single {
WebSocketClient(
Expand Down Expand Up @@ -103,9 +104,9 @@ val clientModule = module {
}

fun provideRestApiHost(): String {
return "10.0.2.2" // Default for Android emulator
return BuildConfig.WS_ANDROID_HOST.takeIf { it.isNotEmpty() } ?: "10.0.2.2"
}

fun provideWebsocketHost(): String {
return "10.0.2.2" // Default for Android emulator
return BuildConfig.WS_ANDROID_HOST.takeIf { it.isNotEmpty() } ?: "10.0.2.2"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package network.bisq.mobile.domain.di

import network.bisq.mobile.client.shared.BuildConfig
import network.bisq.mobile.domain.service.controller.NotificationServiceController
import org.koin.core.qualifier.named
import org.koin.dsl.module
Expand All @@ -16,8 +17,8 @@ val iosClientModule = module {
}

fun provideRestApiHost(): String {
return "localhost"
return BuildConfig.WS_IOS_HOST.takeIf { it.isNotEmpty() } ?: "localhost"
}
fun provideWebsocketHost(): String {
return "localhost"
return BuildConfig.WS_IOS_HOST.takeIf { it.isNotEmpty() } ?: "localhost"
}
32 changes: 0 additions & 32 deletions shared/presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.buildconfig)
alias(libs.plugins.ksp)
}

Expand All @@ -18,37 +17,6 @@ dependencies {

version = project.findProperty("shared.version") as String

// The following allow us to configure each app type independently and link for example with gradle.properties
// TODO potentially to be refactored into a shared/common module
buildConfig {
forClass("network.bisq.mobile.client.shared", className = "BuildConfig") {
buildConfigField("APP_NAME", project.findProperty("client.name").toString())
buildConfigField(
"ANDROID_APP_VERSION",
project.findProperty("client.android.version").toString()
)
buildConfigField("IOS_APP_VERSION", project.findProperty("client.ios.version").toString())
buildConfigField("SHARED_LIBS_VERSION", project.version.toString())
buildConfigField("BUILD_TS", System.currentTimeMillis())
}
forClass("network.bisq.mobile.android.node", className = "BuildNodeConfig") {
buildConfigField("APP_NAME", project.findProperty("node.name").toString())
buildConfigField("APP_VERSION", project.findProperty("node.android.version").toString())
buildConfigField("SHARED_LIBS_VERSION", project.version.toString())
buildConfigField("BUILD_TS", System.currentTimeMillis())
}
// buildConfigField("APP_SECRET", "Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu")
// buildConfigField<String>("OPTIONAL", null)
// buildConfigField("FEATURE_ENABLED", true)
// buildConfigField("MAGIC_NUMBERS", intArrayOf(1, 2, 3, 4))
// buildConfigField("STRING_LIST", arrayOf("a", "b", "c"))
// buildConfigField("MAP", mapOf("a" to 1, "b" to 2))
// buildConfigField("FILE", File("aFile"))
// buildConfigField("URI", uri("https://example.io"))
// buildConfigField("com.github.gmazzo.buildconfig.demos.kts.SomeData", "DATA", "SomeData(\"a\", 1)")

}

kotlin {
androidTarget {
compilations.all {
Expand Down

0 comments on commit 0e688da

Please sign in to comment.