fix: Gradle Args parsing (#1606)

* fix: Gradle Args parsing

* refactor: Applied ARGVParser.parseArgsStringToArgv -> parseArgsStringToArgv suggestion

* test: Added deeper testing for gradle argument parsing
This commit is contained in:
Norman Breau
2023-04-22 17:00:51 -03:00
committed by GitHub
parent a62f699380
commit 3343c3bb34
6 changed files with 158 additions and 15 deletions
+10 -6
View File
@@ -85,7 +85,13 @@ class ProjectBuilder {
}
getArgs (cmd, opts) {
let args;
let args = [
'-b', path.join(this.root, 'build.gradle')
];
if (opts.extraArgs) {
args = args.concat(opts.extraArgs);
}
let buildCmd = cmd;
if (opts.packageType === PackageType.BUNDLE) {
if (cmd === 'release') {
@@ -93,8 +99,6 @@ class ProjectBuilder {
} else if (cmd === 'debug') {
buildCmd = ':app:bundleDebug';
}
args = [buildCmd, '-b', path.join(this.root, 'build.gradle')];
} else {
if (cmd === 'release') {
buildCmd = 'cdvBuildRelease';
@@ -102,14 +106,12 @@ class ProjectBuilder {
buildCmd = 'cdvBuildDebug';
}
args = [buildCmd, '-b', path.join(this.root, 'build.gradle')];
if (opts.arch) {
args.push('-PcdvBuildArch=' + opts.arch);
}
}
args.push.apply(args, opts.extraArgs);
args.push(buildCmd);
return args;
}
@@ -318,6 +320,8 @@ class ProjectBuilder {
const wrapper = path.join(this.root, 'gradlew');
const args = this.getArgs(opts.buildType === 'debug' ? 'debug' : 'release', opts);
events.emit('verbose', `Running Gradle Build: ${wrapper} ${args.join(' ')}`);
try {
return await execa(wrapper, args, { stdio: 'inherit', cwd: path.resolve(this.root) });
} catch (error) {