-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fixes build & run related bugs from builder refactor #490
Conversation
Remaining Tasks
Removing the first build process would have been a better workflow but affects all platforms.
|
bin/templates/cordova/lib/build.js
Outdated
console.log(' \'--nobuild\': will skip build process (useful when using run command)'); | ||
console.log(' \'--prepenv\': don\'t build, but copy in build scripts where necessary'); | ||
console.log(' \'--versionCode=#\': Override versionCode for this build. Useful for uploading multiple APKs. Requires --gradle.'); | ||
console.log(' \'--minSdkVersion=#\': Override minSdkVersion for this build. Useful for uploading multiple APKs. Requires --gradle.'); | ||
console.log(' \'--versionCode=#\': Override versionCode for this build. Useful for uploading multiple APKs..'); |
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.
additional dot at the end
bin/lib/create.js
Outdated
@@ -143,7 +143,7 @@ function writeProjectProperties (projectPath, target_api) { | |||
// This makes no sense, what if you're building with a different build system? | |||
function prepBuildFiles (projectPath, builder) { |
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.
second param probably not needed any more here
return Object.keys(this.binDirs).reduce(function (result, builderName) { | ||
var binDir = self.binDirs[builderName]; | ||
return result.concat(findOutputApksHelper(binDir, build_type, builderName === 'ant' ? null : arch)); | ||
return Object.keys(this.binDirs).reduce((result, builderName) => { |
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.
couldn't binDirs
and this code be simplified to just a string?
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.
Yes, I also think this can be simplified.
Originally I was going to but decided to wait and clean up the other other areas first. Thanks for reminding me this one. I will take a look at it again.
module.exports.getBuilder = function (builderType, projectRoot) { | ||
if (!knownBuilders[builderType]) { throw new CordovaError('Builder ' + builderType + ' is not supported.'); } | ||
|
||
module.exports.getBuilder = function () { |
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.
Couldn't you completely get rid of this? Or is this used from externally?
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 will scan across our repos to verify.
I believe this entire file could be safely removed and point directly to the ProjectBuilder. I am not sure though if anyone uses this in their own personal build system but shouldn't affect us from removing if we don't use.
It might also be possible to do this type of task in separate PR as a final cleanup PR.
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 scanned across repos and it seems only Android uses it. I will say its safe to remove, but I believe a cleanup PR will be better for this so we do not delay the fix.
I tried changing them and it ended up breaking around 70 tests. I would like to focus on that after.
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.
Sure, makes sense to do this individually as it is a major rip-out operation.
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 agree, it's best to leave this for another PR, as it would require a large refactor across the rest of the codebase.
741cc51
to
4d06957
Compare
Codecov Report
@@ Coverage Diff @@
## master #490 +/- ##
==========================================
+ Coverage 59.9% 61.64% +1.73%
==========================================
Files 16 16
Lines 1973 1945 -28
Branches 380 363 -17
==========================================
+ Hits 1182 1199 +17
+ Misses 791 746 -45
Continue to review full report at Codecov.
|
- General Code Refactor - Removed builder type argument from getBuilder API - Removed any reference of conditional statements around builder type - Remove plugin handler install and uninstall option flag android_studio - Remove --gradle flag references - Fixed plugin handler install and uninstall pathing issues - Added parseBuildOptions export so run can get build related options. - Use the nobuild flag option to control the run build. - Updated test spec to reflect the changes.
4d06957
to
1769a9d
Compare
return Q().then(function () { | ||
return PluginManager.get(self.platform, self.locations, project).addPlugin(plugin, installOptions); | ||
}).then(function () { | ||
if (plugin.getFrameworks(this.platform).length === 0) return; | ||
selfEvents.emit('verbose', 'Updating build files since android plugin contained <framework>'); | ||
// This should pick the correct builder, not just get gradle | ||
require('./lib/builders/builders').getBuilder(this.builder).prepBuildFiles(); | ||
require('./lib/builders/builders').getBuilder().prepBuildFiles(); |
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.
Probably for the next round of cleaning, but there's a bunch of stuff around here that could be simplified with arrow functions and could use native Promises.
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 also agree. Some of the things I was thinking about in the clean up PR would be:
- arrow functions
- native promises
let
andconst
- Use
fs-extra
to replace things likeshell.cp
etc. - Remove
builders/builders.js
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.
(Best create a cleanup issue with these tasks so they won't be forgotten)
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.
Will do.
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.
👍 from me
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.
console.log(' \'--nobuild\': will skip build process (useful when using run command)'); | ||
console.log(' \'--prepenv\': don\'t build, but copy in build scripts where necessary'); | ||
console.log(' \'--versionCode=#\': Override versionCode for this build. Useful for uploading multiple APKs. Requires --gradle.'); | ||
console.log(' \'--minSdkVersion=#\': Override minSdkVersion for this build. Useful for uploading multiple APKs. Requires --gradle.'); | ||
console.log(' \'--versionCode=#\': Override versionCode for this build. Useful for uploading multiple APKs.'); |
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.
Do these flags still work with an Android Studio build?
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.
These flag should still work.
It appears that there is an issue where the flags are not being accepted. I am not sure when this issue was introduced but it appears that it also existed in the latest release.
I will create a separate ticket and PR to fix CLI parameter issue.
module.exports.getBuilder = function (builderType, projectRoot) { | ||
if (!knownBuilders[builderType]) { throw new CordovaError('Builder ' + builderType + ' is not supported.'); } | ||
|
||
module.exports.getBuilder = function () { |
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 agree, it's best to leave this for another PR, as it would require a large refactor across the rest of the codebase.
Platforms affected
Android
What does this PR do?
Fixes, refactors, and improves the build and run process that came from the builder refactor.
What testing has been done on this change?
General Tests
npm test
npm run eslint
Default Template
cordova prepare android
cordova compile android
Builds Tested with Device
cordova build android
cordova build android --release --device
cordova build android --debug --device
cordova run android --device
Builds Tested on Emulator
cordova build android
cordova build android --release --emulator
cordova build android --debug --emulator
cordova run android --emulator
Checklist