Skip to content

Commit

Permalink
fix(windows): Gradle paths
Browse files Browse the repository at this point in the history
  • Loading branch information
breautek committed May 9, 2024
1 parent 9683461 commit 20ca9f1
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/builders/ProjectBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const events = require('cordova-common').events;
const CordovaError = require('cordova-common').CordovaError;
const check_reqs = require('../check_reqs');
const PackageType = require('../PackageType');
const { compareByAll } = require('../utils');
const { compareByAll, isWindows } = require('../utils');
const { createEditor } = require('properties-parser');
const CordovaGradleConfigParserFactory = require('../config/CordovaGradleConfigParserFactory');

Expand Down Expand Up @@ -117,6 +117,16 @@ class ProjectBuilder {
return args;
}

getGradleWrapperPath () {
let wrapper = path.join(this.root, 'gradlew');

if (isWindows()) {
wrapper += '.bat';
}

return wrapper;
}

/**
* Installs/updates the gradle wrapper
* @param {string} gradleVersion The gradle version to install. Ignored if CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL environment variable is defined
Expand All @@ -127,7 +137,7 @@ class ProjectBuilder {
throw new CordovaError(`Cannot install Gradle ${gradleVersion}. Minimum Required is ${MIN_GRADLE_REQUIRED}.`);
}

const wrapper = path.join(this.root, 'gradlew');
const wrapper = this.getGradleWrapperPath();
if (process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL) {
events.emit('verbose', `Overriding Gradle Version via CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL (${process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL})`);
await execa(wrapper, ['-p', this.root, 'wrapper', '--gradle-distribution-url', process.env.CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL, '--validate-url'], { stdio: 'inherit' });
Expand Down Expand Up @@ -315,7 +325,7 @@ class ProjectBuilder {
* Returns a promise.
*/
async build (opts) {
const wrapper = path.join(this.root, 'gradlew');
const wrapper = this.getGradleWrapperPath();
const args = this.getArgs(opts.buildType === 'debug' ? 'debug' : 'release', opts);

events.emit('verbose', `Running Gradle Build: ${wrapper} ${args.join(' ')}`);
Expand All @@ -336,7 +346,7 @@ class ProjectBuilder {
}

clean (opts) {
const wrapper = path.join(this.root, 'gradlew');
const wrapper = this.getGradleWrapperPath();
const args = this.getArgs('clean', opts);
return execa(wrapper, args, { stdio: 'inherit', cwd: path.resolve(this.root) })
.then(() => {
Expand Down

0 comments on commit 20ca9f1

Please sign in to comment.