play build: absolute --dir stays absolute; gradlew without exec bit is made executable

This commit is contained in:
CRTkafa 2026-10-29 19:45:18 +07:00
parent 0ea7292164
commit ab69ce020c
5 changed files with 29 additions and 5 deletions

View file

@ -3,7 +3,7 @@
// properties through ORG_GRADLE_PROJECT_* variables, so passwords never appear on a command line), and read
// package / versionCode / versionName back from the built AAB (its manifest is protocol buffers, aapt2 format).
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
import { join, relative } from 'node:path';
import { join, relative, resolve } from 'node:path';
import type { AndroidSigning } from './credentials';
import * as rt from './rt';
import { zipEntries, zipRead } from './zip';
@ -38,7 +38,8 @@ export function pickGradle(root: string, cfg: PlayBuildConfig = {}): GradleTarge
: ['capacitor.config.ts', 'capacitor.config.json', 'capacitor.config.js'].some(f => existsSync(join(root, f))) ? 'capacitor'
: (() => { try { const p = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')); return !!(p.dependencies?.['react-native'] ?? p.devDependencies?.['react-native']); } catch { return false; } })() ? 'react-native'
: 'native';
const dirs = cfg.dir ? [join(root, cfg.dir)] : [join(root, 'android'), root];
// resolve, not join: an absolute play.build.dir / --dir stays absolute (join made /Users/... a folder under the root)
const dirs = cfg.dir ? [resolve(root, cfg.dir)] : [join(root, 'android'), root];
let dir = dirs.find(isGradleDir);
if (!dir) throw new Error(`no Gradle project (settings.gradle) in ${dirs.map(d => relative(root, d) || '.').join(' or ')}: set play.build.dir${framework === 'capacitor' ? ' (or npx cap add android)' : ''}`);
const unity = existsSync(join(dir, 'launcher')) && existsSync(join(dir, 'unityLibrary'));

View file

@ -14,7 +14,7 @@
// The comparison (webStaleness) and the capacitor config reading (webDirOf) are pure.
import { createHash } from 'node:crypto';
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
import { dirname, join, relative, sep } from 'node:path';
import { dirname, join, relative, resolve, sep } from 'node:path';
import type { ShipConfig } from './config';
import { log, warn } from './log';
import { pump } from './runner';
@ -89,7 +89,7 @@ export function capacitorCandidates(root: string): string[] {
*/
export function capacitorProject(root: string, hint?: string): CapProject | null {
if (hint) {
for (let d = join(root, hint); ; d = dirname(d)) {
for (let d = resolve(root, hint); ; d = dirname(d)) {
const rel = relative(root, d);
if (rel.startsWith('..')) break;
const c = capAt(root, rel.split(sep).join('/'));