-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Android builds when gradle args and project dir have spaces #2648
Conversation
} | ||
|
||
return this.$childProcess.spawnFromEvent(gradleBin, ["--stop", "--quiet"], "close", { stdio: "inherit", cwd: projectRoot }); | ||
// TODO: Check if we have to pass compileSdk and other options here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we help with this TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @Plamen5kov , @Pip3r4o for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why we need to call stop and should we pass other options...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just tested it without args and it's working fine, so I'll remove the TODOD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -504,6 +492,19 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject | |||
|
|||
return versionInManifest; | |||
} | |||
|
|||
private async executeGradleCommand(projectRoot: string, gradleArgs: string[], childProcessOpts?: SpawnOptions, spawnFromEventOptions?: ISpawnFromEventOptions): Promise<ISpawnResult> { | |||
const gradleBin = this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename this const to "gradlew" as it points to the wrapper, not gradle itself.
In case you try building application, it will fail in case the following conditions are applied: * build on Windows * build for Android * build in release * path to project dir has spaces * path to certificate (keystore) has spaces OR the certificate(keystore) name itself has spaces OR the password has spaces The problem is in Node.js's `child_process` when `spawn` is used - on Windows it has issues when both the command (in our case this is the FULL PATH to gradlew.bat executable in platforms dir of the project) and ANY of the arguments passed to `child_process's spawn` have spaces. As we are also setting the current working directory of the spawned process to be the path to `<project dir>/platforms/android`, change the `command` passed to `spawn` to be just `gradlew`. This way we'll never have spaces in the command and we'll not hit this issue.
9dee3af
to
e87415f
Compare
In case you try building application, it will fail in case the following conditions are applied:
The problem is in Node.js's
child_process
whenspawn
is used - on Windows it has issues when both the command (in our case this is the FULL PATH to gradlew.bat executable in platforms dir of the project) and ANY of the arguments passed tochild_process's spawn
have spaces.As we are also setting the current working directory of the spawned process to be the path to
<project dir>/platforms/android
, change thecommand
passed tospawn
to be justgradlew
. This way we'll never have spaces in the command and we'll not hit this issue.More information for the Node.js issue: nodejs/node-v0.x-archive#25895
There's a similar issue (linked in the comments of the above) for newer node.js versions. The suggested solution there is to use
{ shell: true}
parameter tospawn
method, but this will require handling of all spaces in the args on our own.