I wrote a simple Gradle plugin to help you version your apps.
github.com/tslamic/versioning/tree/masterPosted Jul 30, 2018, 9:48 AM UTC
Posted Jul 30, 2018, 9:48 AM UTC
Great idea, and I like how you documented it.
One aspect you may want to document in more detail is how this relies on the git history. Most CI environments perform a shallow clone of the repo. How does this affect your plugin?
I’m glad you like it! Great point about shallow cloning. My gut feeling is that it should be OK, but I’ll double check and make sure it’s part of the documentation. Thanks!
Hey Tadej! Guess who ;)
Sweet plugin!
Is there any performance impact when using this for day to day development? Or should it only be enabled in CI environments?
In theory, computing a git tag value every time can affect performance - see here (The section Avoid heavy computations).
Would be interesting to see some benchmarks on that though!
Oh noes, it’s the code review police! :) I haven’t really thought about the performance, good shout! I’ll try to come up with some stats to either confirm or refute this is suitable for everyday use.
One related fun thing I learned the other day was that apply plugin: 'kotlin-android-extensions' was costing 5 seconds (on incremental builds), just for one @Parcelize implementation.
-1 to that!
Did you keep kotlin-android-extensions? Replaced it with something else? Or (gasp) wrote the boilerplate yourself?
I did a quick perf check on the linux kernel source. My MacBook (2.2 GHz Intel Core i7, 16GB ram) spits out this numbers:
$ time git describe --tags --dirty --always
v4.18-rc7-20-g527838d470e3-dirty
real 0m1.098s
user 0m0.310s
sys 0m0.500s
$ time git rev-list --count HEAD
768265
real 0m6.996s
user 0m6.634s
sys 0m0.339s
While the versionCode command is slower than expected, it’s most likely negligible for small and medium size projects (probably large too, unless they’re linux kernel large).
Git, for example, is pretty quick:
$ time git describe --tags --dirty --always
v2.18.0-321-gffc6fa0e3
real 0m0.567s
user 0m0.061s
sys 0m0.085s
$ time git rev-list --count HEAD
52126
real 0m0.757s
user 0m0.618s
sys 0m0.039s
Good stuff.
What if you use something like Gitflow and only tag your builds automatically on a successful CI build when pushed to master?
You’ll end up with version names such as 0.1.0-2-g3cbf60f, which may or may not be ideal.
Looks similar to https://proandroiddev.com/configuring-android-project-version-name-code-b168952f3323, but just cleaner. Any major differences?
Seems similar but also very different to https://github.com/alexfu/androidautoversion.
How does this guarantee that comming major versions has a larger version code than the existing maintenance version?
The biggest issue with this approach is then delivering versions to beta testers, and then wanting to update the live users with a patch.
Exactly what happened here: https://blog.danlew.net/2018/03/15/how-to-screw-over-your-beta-users-without-really-trying/
The version code, being consecutive, will be a big problem in the future.
[deleted]
The plugin is obviously not a silver bullet. I use it for personal projects, where the problems you mention are rarely an issue. That said, it does offer a way to enhance the generated
versionCode, but requires a bit of fiddling: