feat: Android Compose client for the unibus bus
Thin Jetpack Compose UI over the real Go client (pkg/client) compiled to a gomobile .aar, so the phone speaks NATS and runs the same end-to-end crypto as any other peer. Connect, create room (nats/matrix), publish and live-receive.
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
|||||||
|
.gradle/
|
||||||
|
build/
|
||||||
|
local.properties
|
||||||
|
*.iml
|
||||||
|
.idea/
|
||||||
|
captures/
|
||||||
|
.externalNativeBuild/
|
||||||
|
.cxx/
|
||||||
|
*.apk
|
||||||
|
*.aab
|
||||||
|
# NOTE: app/src/test/snapshots/ is committed (Roborazzi goldens are test refs).
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# gallery_kt
|
||||||
|
|
||||||
|
Showcase galeria de todos los componentes @fn_compose en diferentes estados
|
||||||
|
|
||||||
|
Generado con `init_kotlin_app` del registry fn_registry.
|
||||||
|
|
||||||
|
## Requisitos
|
||||||
|
|
||||||
|
- Android SDK 34
|
||||||
|
- JDK 17
|
||||||
|
- Gradle 8.6 (via wrapper)
|
||||||
|
- `kotlin/functions/ui` modulo del registry (composite build)
|
||||||
|
|
||||||
|
## Build rapido
|
||||||
|
|
||||||
|
```bash
|
||||||
|
fn run gradle_assemble_debug_bash_infra apps/gallery_kt
|
||||||
|
```
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
---
|
||||||
|
name: unibus_android
|
||||||
|
domain: tools
|
||||||
|
version: 0.1.0
|
||||||
|
description: "Cliente Android (Jetpack Compose) del bus unibus: conecta, crea salas y chatea con el mismo cliente Go (pkg/client) compilado a un .aar via gomobile, conservando el cifrado E2E."
|
||||||
|
tags: [messaging, nats, e2e, android, compose, kotlin, gomobile, client]
|
||||||
|
lang: kt
|
||||||
|
framework: compose
|
||||||
|
entry_point: "app/src/main/kotlin/com/fnregistry/unibus/MainActivity.kt"
|
||||||
|
dir_path: "projects/message_bus/apps/unibus_android"
|
||||||
|
repo_url: "https://gitea.organic-machine.com/dataforge/unibus_android"
|
||||||
|
uses_functions:
|
||||||
|
- fn_theme_kt_ui
|
||||||
|
- fn_tokens_kt_ui
|
||||||
|
- fn_stack_kt_ui
|
||||||
|
- fn_group_kt_ui
|
||||||
|
- fn_card_kt_ui
|
||||||
|
- fn_badge_kt_ui
|
||||||
|
- fn_button_kt_ui
|
||||||
|
- fn_text_kt_ui
|
||||||
|
- fn_title_kt_ui
|
||||||
|
- fn_text_input_kt_ui
|
||||||
|
- fn_switch_kt_ui
|
||||||
|
uses_types: []
|
||||||
|
e2e_checks:
|
||||||
|
- id: bind
|
||||||
|
cmd: "cd ../unibus && gomobile bind -target=android -androidapi 24 -o ../unibus_android/app/libs/unibus.aar github.com/enmanuel/unibus/mobile"
|
||||||
|
timeout_s: 600
|
||||||
|
- id: build
|
||||||
|
cmd: "fn run gradle_assemble_debug_bash_infra projects/message_bus/apps/unibus_android"
|
||||||
|
timeout_s: 360
|
||||||
|
---
|
||||||
|
|
||||||
|
# unibus_android
|
||||||
|
|
||||||
|
Cliente Android del bus de mensajería `unibus`. La aplicación es una fina capa de
|
||||||
|
interfaz en Jetpack Compose sobre el cliente Go real del bus: `pkg/client` se compila
|
||||||
|
a una librería nativa Android (`unibus.aar`) con `gomobile bind`, de modo que el teléfono
|
||||||
|
habla el protocolo NATS y ejecuta el mismo cifrado end-to-end (ChaCha20-Poly1305 +
|
||||||
|
Ed25519 + X25519) que cualquier otro peer. No se reimplementa ni el protocolo ni la
|
||||||
|
criptografía: hay una única fuente de verdad compartida con el resto del ecosistema.
|
||||||
|
|
||||||
|
## Arquitectura
|
||||||
|
|
||||||
|
```
|
||||||
|
MainActivity.kt (Compose UI)
|
||||||
|
└── mobile.Session (Kotlin, generado por gomobile)
|
||||||
|
└── unibus.aar (libgojni.so: pkg/client + nats.go + crypto del registry)
|
||||||
|
├── data plane → NATS TCP (nats://host:4250)
|
||||||
|
└── control plane → HTTP REST (http://host:8470)
|
||||||
|
```
|
||||||
|
|
||||||
|
El wrapper Go que define la API plana del binding vive en
|
||||||
|
`projects/message_bus/apps/unibus/mobile/unibus.go` (paquete `mobile`): expone
|
||||||
|
`NewSession`, `CreateRoom`, `Join`, `Publish`, `Subscribe`, `Request` y la interfaz
|
||||||
|
`FrameListener` con tipos compatibles con gomobile (string, []byte, int, error,
|
||||||
|
interface).
|
||||||
|
|
||||||
|
## Regenerar el binding (.aar)
|
||||||
|
|
||||||
|
Tras tocar `pkg/client` o el wrapper `mobile/`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd projects/message_bus/apps/unibus
|
||||||
|
export ANDROID_HOME=$HOME/android-sdk
|
||||||
|
export ANDROID_NDK_HOME=$(ls -d $HOME/android-sdk/ndk/* | head -1)
|
||||||
|
export PATH="$PATH:$(go env GOPATH)/bin"
|
||||||
|
gomobile bind -target=android -androidapi 24 \
|
||||||
|
-o ../unibus_android/app/libs/unibus.aar \
|
||||||
|
github.com/enmanuel/unibus/mobile
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build del APK
|
||||||
|
|
||||||
|
```bash
|
||||||
|
fn run gradle_assemble_debug_bash_infra projects/message_bus/apps/unibus_android
|
||||||
|
# o, directo:
|
||||||
|
cd projects/message_bus/apps/unibus_android && ./gradlew :app:assembleDebug
|
||||||
|
# salida: app/build/outputs/apk/debug/app-debug.apk
|
||||||
|
```
|
||||||
|
|
||||||
|
## Probarlo contra el bus
|
||||||
|
|
||||||
|
1. Levantar el control plane real (NATS embebido + REST de membresía):
|
||||||
|
```bash
|
||||||
|
cd projects/message_bus/apps/unibus
|
||||||
|
go run ./cmd/membershipd # HTTP :8470, NATS :4250
|
||||||
|
```
|
||||||
|
2. En el **emulador** (`Pixel_API34`), instalar el APK. La app usa `host = 10.0.2.2`,
|
||||||
|
que el emulador mapea al loopback del PC, así que conecta sin más configuración.
|
||||||
|
3. En la app: Conectar → Crear sala → escribir un mensaje. El mensaje viaja al bus por
|
||||||
|
NATS y vuelve al propio suscriptor (eco del subject), confirmando el camino completo
|
||||||
|
APK → bus → APK.
|
||||||
|
|
||||||
|
## Gotchas
|
||||||
|
|
||||||
|
- `cmd/membershipd` escucha en `127.0.0.1` (líneas `addr := "127.0.0.1:" + httpPort`).
|
||||||
|
Desde el emulador funciona (10.0.2.2 → loopback del host). Para un **teléfono real** en
|
||||||
|
la LAN o vía Tailscale hay que bindear el control plane y el NATS embebido a `0.0.0.0`
|
||||||
|
y usar la IP de red del PC/VPS en los campos Host de la app.
|
||||||
|
- El control plane v1 es HTTP sin TLS; el manifest declara `usesCleartextTraffic="true"`.
|
||||||
|
Para producción, exponer el bus con TLS y quitar ese flag.
|
||||||
|
- El `.aar` pesa ~24 MB (runtime Go embebido) y el APK debug ~54 MB. Es esperado: el
|
||||||
|
cliente Go completo viaja dentro.
|
||||||
|
- `onFrame` del `FrameListener` llega en una goroutine de entrega de NATS; la UI hace
|
||||||
|
`Handler(mainLooper).post { ... }` antes de tocar el estado de Compose.
|
||||||
|
|
||||||
|
## Capability growth log
|
||||||
|
|
||||||
|
- v0.1.0 (2026-06-05) — baseline: conectar, crear sala (modo nats/matrix), publicar y
|
||||||
|
recibir mensajes en vivo. Binding gomobile del `pkg/client` con cifrado E2E intacto.
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
plugins {
|
||||||
|
id("com.android.application") version "8.4.0"
|
||||||
|
id("org.jetbrains.kotlin.android") version "1.9.22"
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "com.fnregistry.unibus"
|
||||||
|
compileSdk = 34
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = "com.fnregistry.unibus"
|
||||||
|
minSdk = 24
|
||||||
|
targetSdk = 34
|
||||||
|
versionCode = 1
|
||||||
|
versionName = "0.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildFeatures {
|
||||||
|
compose = true
|
||||||
|
}
|
||||||
|
composeOptions {
|
||||||
|
kotlinCompilerExtensionVersion = "1.5.8"
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "17"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// unibus client compiled from Go via gomobile: holds the NATS data-plane
|
||||||
|
// connection, the HTTP control-plane calls and the end-to-end crypto. This is
|
||||||
|
// the same pkg/client every other peer uses, so the protocol has one source
|
||||||
|
// of truth.
|
||||||
|
implementation(files("libs/unibus.aar"))
|
||||||
|
|
||||||
|
implementation("androidx.activity:activity-compose:1.8.2")
|
||||||
|
implementation(platform("androidx.compose:compose-bom:2024.02.00"))
|
||||||
|
implementation("androidx.compose.ui:ui")
|
||||||
|
implementation("androidx.compose.material3:material3")
|
||||||
|
implementation("androidx.compose.ui:ui-tooling-preview")
|
||||||
|
debugImplementation("androidx.compose.ui:ui-tooling")
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
|
||||||
|
|
||||||
|
// FnTheme + FnTokens via composite build
|
||||||
|
implementation("fn.compose:ui")
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<!-- Data plane (NATS TCP) and control plane (HTTP) reach the bus over the network. -->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:usesCleartextTraffic="true"
|
||||||
|
android:theme="@android:style/Theme.Material.Light.NoActionBar">
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
package com.fnregistry.unibus
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.activity.compose.setContent
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateListOf
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import fn.compose.theme.FnSpacing
|
||||||
|
import fn.compose.theme.FnTheme
|
||||||
|
import fn.compose.ui.FnBadge
|
||||||
|
import fn.compose.ui.FnBadgeColor
|
||||||
|
import fn.compose.ui.FnButton
|
||||||
|
import fn.compose.ui.FnButtonVariant
|
||||||
|
import fn.compose.ui.FnCard
|
||||||
|
import fn.compose.ui.FnGroup
|
||||||
|
import fn.compose.ui.FnStack
|
||||||
|
import fn.compose.ui.FnSwitch
|
||||||
|
import fn.compose.ui.FnText
|
||||||
|
import fn.compose.ui.FnTextInput
|
||||||
|
import fn.compose.ui.FnTextSize
|
||||||
|
import fn.compose.ui.FnTitle
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
import mobile.FrameListener
|
||||||
|
import mobile.Mobile
|
||||||
|
import mobile.Session
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Single-activity chat client for the unibus message bus. The whole protocol —
|
||||||
|
* NATS data plane, HTTP control plane and end-to-end crypto — lives inside the
|
||||||
|
* gomobile-built unibus.aar (package `mobile`); this UI only orchestrates calls
|
||||||
|
* to a [Session] and renders the frames it delivers.
|
||||||
|
*/
|
||||||
|
class MainActivity : ComponentActivity() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
// The long-term identity (Ed25519 + X25519 keys) is stored in the app's
|
||||||
|
// private files directory, unreadable by other apps.
|
||||||
|
val idPath = File(filesDir, "peer.id").absolutePath
|
||||||
|
setContent {
|
||||||
|
FnTheme {
|
||||||
|
Surface(Modifier.fillMaxSize()) {
|
||||||
|
ChatApp(idPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun ChatApp(idPath: String) {
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
|
// onFrame arrives on a NATS delivery thread; hop to the main thread before
|
||||||
|
// touching Compose state.
|
||||||
|
val mainHandler = remember { Handler(Looper.getMainLooper()) }
|
||||||
|
|
||||||
|
// 10.0.2.2 is the host machine as seen from the Android emulator. On a real
|
||||||
|
// phone, replace it with the PC/VPS LAN or Tailscale address.
|
||||||
|
var host by remember { mutableStateOf("10.0.2.2") }
|
||||||
|
var natsPort by remember { mutableStateOf("4250") }
|
||||||
|
var ctrlPort by remember { mutableStateOf("8470") }
|
||||||
|
var subject by remember { mutableStateOf("room.general") }
|
||||||
|
var e2e by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
var session by remember { mutableStateOf<Session?>(null) }
|
||||||
|
var roomId by remember { mutableStateOf<String?>(null) }
|
||||||
|
var status by remember { mutableStateOf("Desconectado") }
|
||||||
|
var draft by remember { mutableStateOf("") }
|
||||||
|
val messages = remember { mutableStateListOf<String>() }
|
||||||
|
|
||||||
|
val listener = remember {
|
||||||
|
object : FrameListener {
|
||||||
|
override fun onFrame(roomID: String, sender: String, msgID: String, text: String) {
|
||||||
|
mainHandler.post { messages.add("${sender.take(6)} › $text") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FnStack(
|
||||||
|
modifier = Modifier.fillMaxSize().padding(FnSpacing.md),
|
||||||
|
gap = FnSpacing.sm,
|
||||||
|
) {
|
||||||
|
FnTitle("Unibus", order = 2)
|
||||||
|
FnText(status, size = FnTextSize.Sm)
|
||||||
|
|
||||||
|
when {
|
||||||
|
// --- Step 1: connect to the bus ---
|
||||||
|
session == null -> {
|
||||||
|
FnTextInput(
|
||||||
|
value = host,
|
||||||
|
onValueChange = { host = it },
|
||||||
|
label = "Host",
|
||||||
|
placeholder = "10.0.2.2 / IP LAN / tailscale",
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
)
|
||||||
|
FnGroup(gap = FnSpacing.sm) {
|
||||||
|
FnTextInput(value = natsPort, onValueChange = { natsPort = it }, label = "NATS", modifier = Modifier.weight(1f))
|
||||||
|
FnTextInput(value = ctrlPort, onValueChange = { ctrlPort = it }, label = "Control", modifier = Modifier.weight(1f))
|
||||||
|
}
|
||||||
|
FnButton("Conectar", onClick = {
|
||||||
|
status = "Conectando…"
|
||||||
|
scope.launch {
|
||||||
|
try {
|
||||||
|
val s = withContext(Dispatchers.IO) {
|
||||||
|
Mobile.newSession(idPath, "nats://$host:$natsPort", "http://$host:$ctrlPort")
|
||||||
|
}
|
||||||
|
session = s
|
||||||
|
status = "Conectado · ${s.endpointID().take(10)}"
|
||||||
|
} catch (e: Exception) {
|
||||||
|
status = "Error al conectar: ${e.message}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, modifier = Modifier.fillMaxWidth())
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Step 2: open a room ---
|
||||||
|
roomId == null -> {
|
||||||
|
FnTextInput(
|
||||||
|
value = subject,
|
||||||
|
onValueChange = { subject = it },
|
||||||
|
label = "Subject de la sala",
|
||||||
|
placeholder = "room.general",
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
)
|
||||||
|
FnSwitch(checked = e2e, onCheckedChange = { e2e = it }, label = "Cifrado E2E (modo matrix)")
|
||||||
|
FnButton("Crear sala", onClick = {
|
||||||
|
status = "Creando sala…"
|
||||||
|
scope.launch {
|
||||||
|
try {
|
||||||
|
val mode = if (e2e) "matrix" else "nats"
|
||||||
|
val rid = withContext(Dispatchers.IO) {
|
||||||
|
val r = session!!.createRoom(subject, mode)
|
||||||
|
session!!.join(r)
|
||||||
|
session!!.subscribe(r, listener)
|
||||||
|
r
|
||||||
|
}
|
||||||
|
roomId = rid
|
||||||
|
status = "Sala activa"
|
||||||
|
} catch (e: Exception) {
|
||||||
|
status = "Error al crear sala: ${e.message}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, modifier = Modifier.fillMaxWidth())
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Step 3: chat ---
|
||||||
|
else -> {
|
||||||
|
FnGroup(gap = FnSpacing.sm) {
|
||||||
|
FnBadge(if (e2e) "E2E" else "PLAIN", color = if (e2e) FnBadgeColor.Green else FnBadgeColor.Gray)
|
||||||
|
FnText(subject, size = FnTextSize.Xs)
|
||||||
|
}
|
||||||
|
FnCard(modifier = Modifier.fillMaxWidth().weight(1f)) {
|
||||||
|
FnStack(
|
||||||
|
modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()),
|
||||||
|
gap = FnSpacing.xs,
|
||||||
|
) {
|
||||||
|
if (messages.isEmpty()) {
|
||||||
|
FnText("Sin mensajes todavía. Envía el primero.", size = FnTextSize.Sm)
|
||||||
|
} else {
|
||||||
|
messages.forEach { FnText(it, size = FnTextSize.Sm) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FnGroup(gap = FnSpacing.sm) {
|
||||||
|
FnTextInput(
|
||||||
|
value = draft,
|
||||||
|
onValueChange = { draft = it },
|
||||||
|
label = "Mensaje",
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
)
|
||||||
|
FnButton("Enviar", onClick = {
|
||||||
|
val text = draft.trim()
|
||||||
|
if (text.isEmpty()) return@FnButton
|
||||||
|
draft = ""
|
||||||
|
scope.launch {
|
||||||
|
try {
|
||||||
|
withContext(Dispatchers.IO) { session!!.publish(roomId!!, text) }
|
||||||
|
} catch (e: Exception) {
|
||||||
|
status = "Error al enviar: ${e.message}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, variant = FnButtonVariant.Filled)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">Unibus</string>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
plugins {
|
||||||
|
id("com.android.application") version "8.4.0" apply false
|
||||||
|
id("org.jetbrains.kotlin.android") version "1.9.22" apply false
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||||
|
android.useAndroidX=true
|
||||||
|
kotlin.code.style=official
|
||||||
|
android.nonTransitiveRClass=true
|
||||||
Vendored
BIN
Binary file not shown.
+7
@@ -0,0 +1,7 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH="\\\"\\\""
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rootProject.name = "unibus_android"
|
||||||
|
include(":app")
|
||||||
|
|
||||||
|
// Composite build: FnTheme + FnTokens design system from the registry (fn.compose:ui).
|
||||||
|
// Path climbs apps/unibus_android -> apps -> message_bus -> projects -> fn_registry.
|
||||||
|
includeBuild("../../../../kotlin/functions/ui") {
|
||||||
|
dependencySubstitution {
|
||||||
|
substitute(module("fn.compose:ui")).using(project(":"))
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user