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

Support SDK versions with pre-release identifiers #709

Merged
merged 1 commit into from
Jan 14, 2020

Conversation

wmramazan
Copy link
Contributor

@wmramazan wmramazan commented Apr 2, 2019

Platforms affected

Android

Motivation and Context

Fixes #708

Description

I changed the regular expression for versions of build tools in cordova.gradle file in order to accept all possible versions. And I removed the tag of release life cycle in version string when comparing them.

29.0.0-rc1 => 29.0.0

Testing

I built an example project with both Android SDK Build-Tools 28.0.0 and 29.0.0-rc1.

Checklist

  • 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

@codecov-io
Copy link

Codecov Report

Merging #709 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #709   +/-   ##
=======================================
  Coverage   64.38%   64.38%           
=======================================
  Files          18       18           
  Lines        1828     1828           
=======================================
  Hits         1177     1177           
  Misses        651      651

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 9531dbb...ed28193. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Apr 2, 2019

Codecov Report

Merging #709 into master will increase coverage by 0.4%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #709     +/-   ##
=========================================
+ Coverage   63.98%   64.38%   +0.4%     
=========================================
  Files          18       18             
  Lines        1824     1828      +4     
=========================================
+ Hits         1167     1177     +10     
+ Misses        657      651      -6
Impacted Files Coverage Δ
...lates/cordova/lib/config/GradlePropertiesParser.js 74.07% <0%> (-2.6%) ⬇️
bin/templates/cordova/lib/build.js 26.01% <0%> (-0.76%) ⬇️
bin/templates/cordova/lib/AndroidManifest.js 100% <0%> (ø) ⬆️
bin/lib/create.js 92.72% <0%> (ø) ⬆️
bin/templates/cordova/lib/prepare.js 36.3% <0%> (+0.49%) ⬆️

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 b177f84...66ffe30. 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.

Firstly, thanks for taking the time to submit the issue and this PR.

Secondly, I pointed out a few potentially problematic places in your code. IMO, we really should ensure that 20.0.0-rc1 < 20.0.0 and for that, you probably have to add the pre-release identifiers to the token lists.

Lastly, it would be great if we could use an external library to do the version comparison. Version Compare looks promising. We should be able to include that using the following code:

buildscript {
   dependencies {
      classpath 'com.g00fy2:versioncompare:1.3.1@jar'
   }
}

framework/cordova.gradle Outdated Show resolved Hide resolved
// "19.0.0" > "19"
// "19.0.1" > "19.0.0"
// "19.1.0" > "19.0.1"
// "19" > "18.999.999"
int compareVersions(String a, String b) {
a = removeTagOfReleaseLifeCycle(a)
b = removeTagOfReleaseLifeCycle(b)
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICT, with this code 20.0.0-rc1 == 20.0.0 would hold. Whereas I would expect 20.0.0-rc1 < 20.0.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review.

I thought that Android SDK Manager will change the version string by removing the pre-release identifier after the release so we don't need to compare with pre-release identifiers. But some users may use all versions of build-tools for debugging.

I don't know that the 3rd party libraries can be used for the solution. Is it acceptable for the project? It may cause vulnerability and reduce consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

We use tons of 3rd party libraries on the Node.js side of our tools, so I don't see why we should not use Java/Groovy libraries. Especially when it's only a compile time dependency. I'm always happy when we can reduce the amount of code we have to maintain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, thanks a lot. I am going to use the library.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! Thanks for giving this another go.

@raphinesse raphinesse changed the title Android - Closes #708. Support SDK versions with pre-release identifiers Apr 2, 2019
@raphinesse raphinesse added the bug label Apr 2, 2019
@raphinesse
Copy link
Contributor

@wmramazan Thanks for the update. But why did you include all the changes outside of framework/build.gradle?

@wmramazan
Copy link
Contributor Author

I just wanted to update the project for the new version of Android Studio.

@raphinesse
Copy link
Contributor

Please undo any changes that are not directly related to the problem we try to solve here. Please mind the commit I added when doing that.

Closes apache#708.
Do not rely on our own version regex anymore
Revert "Do not rely on our own version regex anymore"
This reverts commit 6b3345e.
Revert "Closes apache#708."
This reverts commit 8d9a1f5.
Add version-compare library to compare build-tools versions properly.
@raphinesse
Copy link
Contributor

Thanks for the update and for fixing my commit @wmramazan. The modified file looks good to me. Do you have any remarks on the bigger picture @erisu?

@erisu erisu added this to the 9.0.0 milestone Jan 6, 2020
Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

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

Code LGTM

@erisu erisu merged commit f4b8f44 into apache:master Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cordova.gradle does not compare versions properly.
4 participants