mirror of
https://github.com/margrop/wrong-notebook.git
synced 2026-12-05 11:29:51 +08:00
- 安卓工程增加 mode 维度:standalone 单机版(包名 .standalone)与 client 客户端版,各分手机版、平板版 - 单机版内置 Termux 的 Node.js 24 及依赖库、交叉编译的 Prisma 查询引擎与迁移引擎,放入 jniLibs 以便执行;服务端打包为 assets/server.zip,首次启动解压 - LocalServer 用通用启动器在 127.0.0.1:38017 启动服务端(复制预置数据库、执行迁移),进程被系统回收后回到前台自动重启 - 新增 build-android-prisma-engines.sh(按 Prisma 引擎提交交叉编译)与 android-runtime.mjs(下载并校验 Termux 软件包、patchelf 改写库名、组装运行时) - build.mjs android 支持 --mode;单机版产物为 WrongNotebook-Android-Phone/Tablet-<版本>.apk - CI 安卓 Job 构建 bundle、缓存并编译安卓 Prisma 引擎 - 「设置 → 关于」在单机版中说明数据保存在本机,不显示更换服务器 - 同步更新 README、安装包文档、Wiki 与测试 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
112 lines
3.8 KiB
Groovy
112 lines
3.8 KiB
Groovy
plugins {
|
||
id 'com.android.application'
|
||
}
|
||
|
||
// 版本号由 scripts/package/build.mjs 根据发布标签传入(-PappVersionName / -PappVersionCode)
|
||
def appVersionName = project.findProperty('appVersionName') ?: '0.0.0-dev'
|
||
def appVersionCode = (project.findProperty('appVersionCode') ?: '1') as Integer
|
||
|
||
// 发布签名:通过环境变量提供密钥库,未提供时 release 构建使用调试签名,仅供本地测试
|
||
def keystoreFile = System.getenv('ANDROID_KEYSTORE_FILE')
|
||
def hasReleaseKey = keystoreFile && file(keystoreFile).exists()
|
||
|
||
// 单机版内置的运行时(Node.js、Prisma 引擎、服务端),由 scripts/package/build.mjs android 生成
|
||
def standaloneRuntimeDir = file(project.findProperty('standaloneRuntimeDir') ?: rootProject.file('../../dist/android-runtime'))
|
||
|
||
android {
|
||
namespace 'com.margrop.wrongnotebook'
|
||
compileSdk 35
|
||
buildToolsVersion '35.0.0'
|
||
|
||
defaultConfig {
|
||
applicationId 'com.margrop.wrongnotebook'
|
||
minSdk 24
|
||
targetSdk 35
|
||
versionCode appVersionCode
|
||
versionName appVersionName
|
||
}
|
||
|
||
signingConfigs {
|
||
if (hasReleaseKey) {
|
||
release {
|
||
storeFile file(keystoreFile)
|
||
storePassword System.getenv('ANDROID_KEYSTORE_PASSWORD')
|
||
keyAlias System.getenv('ANDROID_KEY_ALIAS')
|
||
keyPassword System.getenv('ANDROID_KEY_PASSWORD') ?: System.getenv('ANDROID_KEYSTORE_PASSWORD')
|
||
}
|
||
}
|
||
}
|
||
|
||
// mode:单机版在手机上运行完整服务端;客户端版连接已部署的服务器,沿用原包名以便覆盖升级
|
||
// device:手机版锁定竖屏;平板版跟随系统旋转,横竖屏均可使用
|
||
flavorDimensions = ['mode', 'device']
|
||
productFlavors {
|
||
standalone {
|
||
dimension 'mode'
|
||
applicationIdSuffix '.standalone'
|
||
// 内置服务端用到 ProcessBuilder 输出重定向等 Android 8.0 的接口
|
||
minSdk 26
|
||
manifestPlaceholders += [appLabel: '@string/app_name']
|
||
buildConfigField 'boolean', 'STANDALONE', 'true'
|
||
// 内置的 Node.js 和 Prisma 引擎只编译了 arm64-v8a
|
||
ndk { abiFilters 'arm64-v8a' }
|
||
}
|
||
client {
|
||
dimension 'mode'
|
||
manifestPlaceholders += [appLabel: '@string/app_name_client']
|
||
buildConfigField 'boolean', 'STANDALONE', 'false'
|
||
}
|
||
phone {
|
||
dimension 'device'
|
||
manifestPlaceholders += [screenOrientation: 'portrait']
|
||
buildConfigField 'String', 'DEVICE_TYPE', '"phone"'
|
||
}
|
||
tablet {
|
||
dimension 'device'
|
||
manifestPlaceholders += [screenOrientation: 'fullUser']
|
||
buildConfigField 'String', 'DEVICE_TYPE', '"tablet"'
|
||
}
|
||
}
|
||
|
||
sourceSets {
|
||
standalone {
|
||
jniLibs.srcDirs = [new File(standaloneRuntimeDir, 'jniLibs')]
|
||
assets.srcDirs += [new File(standaloneRuntimeDir, 'assets')]
|
||
}
|
||
}
|
||
|
||
packaging {
|
||
jniLibs {
|
||
// 内置的 node 和迁移引擎是可执行文件,必须解压到 nativeLibraryDir 才能运行
|
||
useLegacyPackaging true
|
||
// 已用 patchelf 改写过库名,不再由构建工具剥离符号
|
||
keepDebugSymbols += ['**/*.so']
|
||
}
|
||
}
|
||
|
||
androidResources {
|
||
// server.zip 本身已压缩,原样存放可加快首次启动时的解压
|
||
noCompress += ['zip']
|
||
}
|
||
|
||
buildTypes {
|
||
release {
|
||
minifyEnabled false
|
||
signingConfig hasReleaseKey ? signingConfigs.release : signingConfigs.debug
|
||
}
|
||
}
|
||
|
||
buildFeatures {
|
||
buildConfig true
|
||
}
|
||
|
||
compileOptions {
|
||
sourceCompatibility JavaVersion.VERSION_17
|
||
targetCompatibility JavaVersion.VERSION_17
|
||
}
|
||
}
|
||
|
||
dependencies {
|
||
implementation 'androidx.core:core:1.13.1'
|
||
}
|