From 8215ce14c6e889ba11c61dbe8cc25f2d75f2f62f Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sat, 13 May 2023 15:54:17 +0100 Subject: [PATCH] Tools: Allow different Android variants --- packages/app-mobile/android/app/build.gradle | 10 ++++++++++ packages/tools/release-android.ts | 17 +++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/packages/app-mobile/android/app/build.gradle b/packages/app-mobile/android/app/build.gradle index 4d830011b..d8148cb36 100644 --- a/packages/app-mobile/android/app/build.gradle +++ b/packages/app-mobile/android/app/build.gradle @@ -139,6 +139,16 @@ def reactNativeArchitectures() { } android { + flavorDimensions "version" + + productFlavors { + mod { + dimension "version" + applicationIdSuffix ".mod" + versionNameSuffix = "-mod" + } + } + compileSdkVersion rootProject.ext.compileSdkVersion compileOptions { diff --git a/packages/tools/release-android.ts b/packages/tools/release-android.ts index 7a5f7f1dc..1ab57f8a3 100644 --- a/packages/tools/release-android.ts +++ b/packages/tools/release-android.ts @@ -94,6 +94,11 @@ function gradleVersionName(content: string) { return matches[1]; } +const assembleCommandName = (releaseName: string) => { + if (releaseName === 'vosk') return 'assembleMod'; + return 'assembleRelease'; +}; + async function createRelease(projectName: string, name: string, tagName: string, version: string): Promise { const suffix = version + (name === 'main' ? '' : `-${name}`); @@ -114,11 +119,11 @@ async function createRelease(projectName: string, name: string, tagName: string, return readFile(`${rnDir}/services/voiceTyping/vosk.dummy.ts`, 'utf8'); }); - await patcher.updateFileContent(`${rnDir}/android/app/build.gradle`, async (content: string) => { - content = content.replace(/\s+"react-native-vosk": ".*",/, ''); - content = content.replace(/(\s+)"applicationId "net.cozic.joplin"/, '$1"applicationId "net.cozic.joplin-mod"'); - return content; - }); + // await patcher.updateFileContent(`${rnDir}/android/app/build.gradle`, async (content: string) => { + // content = content.replace(/\s+"react-native-vosk": ".*",/, ''); + // content = content.replace(/(\s+)"applicationId "net.cozic.joplin"/, '$1"applicationId "net.cozic.joplin-mod"'); + // return content; + // }); await patcher.removeFile(`${rnDir}/android/app/src/main/assets/model-fr-fr`); } @@ -143,7 +148,7 @@ async function createRelease(projectName: string, name: string, tagName: string, let restoreDir = null; let apkBuildCmd = ''; let apkCleanBuild = ''; - const apkBuildCmdArgs = ['assembleRelease', `-PbuildDir=${buildDirName}`]; // TOOD: change build dir, delete before + const apkBuildCmdArgs = [assembleCommandName(name), `-PbuildDir=${buildDirName}`]; if (await fileExists('/mnt/c/Windows/System32/cmd.exe')) { await execCommandWithPipes('/mnt/c/Windows/System32/cmd.exe', ['/c', `cd packages\\app-mobile\\android && gradlew.bat ${apkBuildCmd}`]); apkBuildCmd = '';