Skip to content
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

enhancement: Control project properties in one place #1211

Closed
wants to merge 5 commits into from

Conversation

breautek
Copy link
Contributor

Platforms affected

Android

Motivation and Context

Currently when we want to bump certain variables such as our gradle version, we have several files we need to keep track of and update. This is an enhancement that allows us to define a single variable such as the gradle version, or our target/min SDK versions in a single place.

Description

framework now contains a defaults.json file which contains several constants such the gradle version, among other constants which is used throughout both nodejs and gradle to set our defaults values.

Our androidx native unit test also makes use of this file to set its min sdk/target sdk/build tools, etc.

If there is anything else that should be included in the defaults constants I'd be happy to add them.

Testing

npm test and manual testing

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@breautek breautek added this to the 10.0.0 milestone Apr 18, 2021
@codecov-commenter
Copy link

codecov-commenter commented Apr 18, 2021

Codecov Report

❗ No coverage uploaded for pull request base (master@b2d9d63). Click here to learn what that means.
The diff coverage is 88.46%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1211   +/-   ##
=========================================
  Coverage          ?   72.14%           
=========================================
  Files             ?       22           
  Lines             ?     1709           
  Branches          ?        0           
=========================================
  Hits              ?     1233           
  Misses            ?      476           
  Partials          ?        0           
Impacted Files Coverage Δ
...n/templates/cordova/lib/builders/ProjectBuilder.js 73.85% <0.00%> (ø)
...lates/cordova/lib/config/GradlePropertiesParser.js 86.27% <ø> (ø)
bin/lib/create.js 94.90% <100.00%> (ø)
bin/templates/cordova/lib/TemplateFile.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b2d9d63...66a0953. Read the comment docs.

Copy link
Contributor

@raphinesse raphinesse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great to see that someone is tackling this issue. It is something that has bugged me for a long time 👍.

I left a few comments, most of which concern only minor details. One big thing that confuses me is the variable interpolation applied to various files in create.js. It seems that only one file is actually making use of the interpolation. Is this a leftover from a previous version or am I missing something here?

It would be great if we had as little templating as possible IMHO. It just adds another layer of complexity. And if project.properties really was the only file that used templating, I'd suggest a simpler approach for it than the TemplateFile class.

bin/templates/cordova/lib/builders/ProjectBuilder.js Outdated Show resolved Hide resolved
bin/templates/cordova/lib/builders/ProjectBuilder.js Outdated Show resolved Hide resolved
bin/templates/cordova/lib/builders/ProjectBuilder.js Outdated Show resolved Hide resolved
privateHelpers.getProjectTarget = { doGetProjectTarget() }
privateHelpers.findLatestInstalledBuildTools = { doFindLatestInstalledBuildTools('19.1.0') }
privateHelpers.findLatestInstalledBuildTools = { doFindLatestInstalledBuildTools("29.0.2") }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that version not something we can/should move to a config? I'm seriously asking, no idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah, in fact we already have a variable for it, so good catch

bin/templates/cordova/lib/check_reqs.js Outdated Show resolved Hide resolved
spec/unit/check_reqs.spec.js Outdated Show resolved Hide resolved
DEFAULT_SDK_VERSION: targetAPI || constants.DEFAULT_SDK_VERSION,
DEFAULTS_FILE_PATH: './defaults.json'
});
TemplateFile.render(path.join(ROOT, 'framework', 'build.gradle'), path.join(nestedCordovaLibPath, 'build.gradle'), {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only file that seems to actually make use of interpolating template variables is project.properties. Did you refactor something and this is leftovers or did I not get something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah -- I must have forgot to revert. Original (unreleased) version of this PR actually used them, but then I refactored so that the gradle environment can just load in a JSON file itself (which allowed me to also utilize these constants for our test environments)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I think the JSON file is definitely the better solution 👍

@breautek breautek marked this pull request as draft April 19, 2021 00:54
@breautek
Copy link
Contributor Author

Thanks @raphinesse for the in-depth review. Obviously I still have some work to do so I set this to a draft for now. I'll try to clean up the PR and address all the concerns you've brought up this weekend coming.

breautek and others added 3 commits April 18, 2021 22:32
Co-authored-by: Raphael von der Grün <raphinesse@gmail.com>
Co-authored-by: Raphael von der Grün <raphinesse@gmail.com>
@breautek breautek force-pushed the enhancements/constant-power branch from 39c08af to c7e02e0 Compare April 19, 2021 01:32
Co-authored-by: Raphael von der Grün <raphinesse@gmail.com>
@breautek breautek force-pushed the enhancements/constant-power branch from c7e02e0 to 26897e2 Compare April 19, 2021 01:33
@breautek
Copy link
Contributor Author

Closing this in favour of #1212

@breautek breautek closed this Apr 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants