apache / apache/cordova-android
Issue with gradleArg parameter not being used when created gradle wrapper
- Dominant language
- JavaScript
- Stars
- 3.8k
- Forks
- 1.6k
- Avg merge
- 16h 18m
- Merged PRs (30d)
- 11
Description
# Bug Report
## Problem
gradleArg is not being passed to the gradle command when it is creating the wrapper and I was using gradleArg=--project-cache-dir=/tmp because my project directory is on a Windows file server. If I ran the gradle command manually with my --project-cache-dir everything worked fine, but I could not build using the cordova command directly.
### What is expected to happen?
Extra gradle arguments are passed through the command line to gradle using cordova commands.
### What does actually happen?
It works except when cordova is creating the gradle wrapper during prepEnv.
## Information
To get this to work I added an opts parameter to runGradleWrapper in ProjectBuilder.js. This passed in the arguments successfully and I was able to generate an APK using a Mac device with my project folder existing on a Windows file server using the --gradleArg=--project-cache-dir=/tmp.
### Command or Code
Added opts to ProjectBuilder.js:
/*
* This returns a promise
*/
runGradleWrapper (gradle_cmd, opts) {
var gradlePath = path.join(this.root, 'gradlew');
var wrapperGradle = path.join(this.root, 'wrapper.gradle');
if (fs.existsSync(gradlePath)) {
// Literally do nothing, for some reason this works, while !fs.existsSync didn't on Windows
} else if (opts.extraArgs) {
return execa(gradle_cmd, ['-p', this.root, 'wrapper', '-b', wrapperGradle, opts.extraArgs], { stdio: 'inherit' });
}
else {
return execa(gradle_cmd, ['-p', this.root, 'wrapper', '-b', wrapperGradle], { stdio: 'inherit' });
}
}
prepEnv (opts) {
var self = this;
return check_reqs.check_gradle()
.then(function (gradlePath) {
return self.runGradleWrapper(gradlePath, opts);
}).then(function () {
return self.prepBuildFiles();
}).then(() => {
### Environment, Platform, Device
Mac OS with project on Windows file server (SMB).
### Version information
## Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
Contributor guide
Research direction
Start in ProjectBuilder.js, focusing on runGradleWrapper and how prepEnv passes options while creating the Gradle wrapper. Reproduce the Cordova build with gradleArg=--project-cache-dir=/tmp on the described setup, then verify that the extra argument reaches the wrapper-generation command and the APK build succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system, mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100