fix: patch capacitor.settings.gradle to use ../cinny/node_modules for Linux CI
Some checks failed
Build / increment-version (push) Successful in 6s
Build / build-android (push) Failing after 3m1s
Build / create-release (push) Has been skipped

This commit is contained in:
2026-04-07 15:56:51 +10:00
parent f2e17c1763
commit ffe99d8431
2 changed files with 30 additions and 0 deletions

View File

@@ -9,6 +9,9 @@
* 5. Copies capacitor.config.json (root) into cinny/capacitor.config.json with webDir reset to "dist" * 5. Copies capacitor.config.json (root) into cinny/capacitor.config.json with webDir reset to "dist"
* 6. Creates a cinny/android symlink/junction -> root android/ so Capacitor can find it * 6. Creates a cinny/android symlink/junction -> root android/ so Capacitor can find it
* 7. Writes android/local.properties from ANDROID_HOME env var (so it works on any machine) * 7. Writes android/local.properties from ANDROID_HOME env var (so it works on any machine)
* 8. Patches android/capacitor.settings.gradle to use ../cinny/node_modules instead of
* ../node_modules, so Gradle resolves the correct path on both Windows (junction) and
* Linux (symlink, where Java resolves CWD to the real ROOT/android/ path)
* *
* Run before every Android build to keep the cinny submodule clean while layering * Run before every Android build to keep the cinny submodule clean while layering
* the Capacitor / Android platform changes on top of it. * the Capacitor / Android platform changes on top of it.
@@ -133,4 +136,22 @@ if (androidHome) {
console.warn('[apply-overlay] Warning: ANDROID_HOME not set, skipping local.properties update'); console.warn('[apply-overlay] Warning: ANDROID_HOME not set, skipping local.properties update');
} }
// 8. Patch android/capacitor.settings.gradle to use ../cinny/node_modules
// On Linux, Java resolves the symlink for CWD so Gradle sees ROOT/android/ as its project
// directory, making ../node_modules point to ROOT/node_modules (wrong). On Windows, the
// junction keeps the logical path cinny/android so ../node_modules resolves correctly to
// cinny/node_modules. Patching to ../cinny/node_modules works on both:
// Linux: ROOT/android/../cinny/node_modules = ROOT/cinny/node_modules ✓
// Windows: cinny/android/../cinny/node_modules = cinny/node_modules ✓
console.log('[apply-overlay] Patching android/capacitor.settings.gradle...');
const capSettingsPath = join(androidTarget, 'capacitor.settings.gradle');
const original = readFileSync(capSettingsPath, 'utf8');
const patched = original.replaceAll('../node_modules/', '../cinny/node_modules/');
if (patched !== original) {
writeFileSync(capSettingsPath, patched, 'utf8');
console.log(' patched ../node_modules/ -> ../cinny/node_modules/');
} else {
console.log(' already patched or no replacements needed');
}
console.log('[apply-overlay] Done.'); console.log('[apply-overlay] Done.');

View File

@@ -22,6 +22,15 @@ const STASH_FLAG = join(ROOT, '.cinny-stash-pending');
console.log('[restore-cinny] Reverting tracked changes...'); console.log('[restore-cinny] Reverting tracked changes...');
execSync('git checkout -- .', { cwd: CINNY, stdio: 'inherit' }); execSync('git checkout -- .', { cwd: CINNY, stdio: 'inherit' });
// Restore android/capacitor.settings.gradle patched by apply-overlay
console.log('[restore-cinny] Restoring android/capacitor.settings.gradle...');
try {
execSync('git checkout -- android/capacitor.settings.gradle', { cwd: ROOT, stdio: 'inherit' });
console.log('[restore-cinny] Restored android/capacitor.settings.gradle');
} catch {
console.warn('[restore-cinny] Could not restore capacitor.settings.gradle (may not be modified)');
}
// 2. Remove untracked capacitor.config.json written by the overlay // 2. Remove untracked capacitor.config.json written by the overlay
const capConfig = join(CINNY, 'capacitor.config.json'); const capConfig = join(CINNY, 'capacitor.config.json');
if (existsSync(capConfig)) { if (existsSync(capConfig)) {