mirror of
https://github.com/laurent22/joplin.git
synced 2026-05-07 20:02:45 +00:00
Chore: Fixed Android release script
This commit is contained in:
@@ -3,13 +3,59 @@
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
function deleteMatchingDirs(rootDir, predicate) {
|
||||
let entries;
|
||||
try {
|
||||
entries = fs.readdirSync(rootDir, { withFileTypes: true });
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const entry of entries) {
|
||||
if (!entry.isDirectory()) continue;
|
||||
|
||||
const fullPath = `${rootDir}/${entry.name}`;
|
||||
|
||||
if (predicate(fullPath)) {
|
||||
fs.rmSync(fullPath, { recursive: true, force: true });
|
||||
} else {
|
||||
deleteMatchingDirs(fullPath, predicate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
const mobileDir = `${__dirname}/..`;
|
||||
|
||||
// Standard Android / iOS build artefacts
|
||||
fs.rmSync(`${mobileDir}/android/.gradle`, { recursive: true, force: true });
|
||||
fs.rmSync(`${mobileDir}/android/app/build`, { recursive: true, force: true });
|
||||
fs.rmSync(`${mobileDir}/android/build`, { recursive: true, force: true });
|
||||
fs.rmSync(`${mobileDir}/android/app/build`, { recursive: true, force: true });
|
||||
fs.rmSync(`${mobileDir}/android/.cxx`, { recursive: true, force: true });
|
||||
fs.rmSync(`${mobileDir}/android/app/.cxx`, { recursive: true, force: true });
|
||||
|
||||
// React Native generated files that frequently break CMake/autolinking
|
||||
fs.rmSync(`${mobileDir}/android/app/build/generated/autolinking`, { recursive: true, force: true });
|
||||
fs.rmSync(`${mobileDir}/android/app/build/generated/source/codegen`, { recursive: true, force: true });
|
||||
|
||||
// iOS
|
||||
fs.rmSync(`${mobileDir}/ios/Pods`, { recursive: true, force: true });
|
||||
console.info('To clean the Android build, in some rare cases you might also need to clear the cache in ~/.android and ~/.gradle');
|
||||
|
||||
// Delete all native module Android build artefacts
|
||||
// Equivalent to:
|
||||
// find . -path "*/node_modules/*/android/build" -type d -exec rm -rf {} + || true
|
||||
// find . -path "*/node_modules/*/android/.cxx" -type d -exec rm -rf {} + || true
|
||||
deleteMatchingDirs(mobileDir, p =>
|
||||
p.includes('/node_modules/') && (
|
||||
p.endsWith('/android/build') ||
|
||||
p.endsWith('/android/.cxx')
|
||||
),
|
||||
);
|
||||
|
||||
console.info(
|
||||
'Mobile app build artefacts cleaned.\n' +
|
||||
'If you still see build issues, you may also need to clear ~/.gradle/caches and ~/.android.',
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -247,3 +247,4 @@ youtu
|
||||
nocookie
|
||||
fgag
|
||||
mrjo
|
||||
codegen
|
||||
|
||||
@@ -148,7 +148,15 @@ async function createRelease(projectName: string, releaseConfig: ReleaseConfig,
|
||||
} else {
|
||||
process.chdir(`${rnDir}/android`);
|
||||
apkBuildCmd = './gradlew';
|
||||
apkCleanBuild = `./gradlew clean -PbuildDir=${buildDirName}`;
|
||||
|
||||
// Note: We intentionally do NOT run `./gradlew clean`. On React Native 0.8x+, `clean` is
|
||||
// broken because it triggers CMake regeneration via externalNativeBuild, which re-evaluates
|
||||
// autolinking and codegen and fails if generated JNI/CMake directories are missing (and for
|
||||
// some reason they usually are). Manually deleting build artefacts is safer and
|
||||
// deterministic.
|
||||
|
||||
// apkCleanBuild = `./gradlew clean -PbuildDir=${buildDirName}`;
|
||||
apkCleanBuild = 'yarn clean';
|
||||
restoreDir = rootDir;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user