-
Notifications
You must be signed in to change notification settings - Fork 12
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
[Feature Request] Support for app version #1
Comments
I believe this would require making a gradle plugin. I need to look into it before committing to it. |
Read it from the BuildConfig ;) |
@vanniktech Would he be able to read the BuildConfig of the app, and not just the library's BuildConfig? |
See which class was annotated with Imagine MyClass is annotated: then just try getting Buildconfig via:
at some point you'll get it and then you can go and use it. |
Heh, that could work. Although it would be problematic for if you have a seperate package name from your appId (such as if you were using an imported third party library or something). Possibly you could also do something like |
There is also this which is something they might work on and with it you'll get the application id |
At this point the library works for non-Android projects. The BuildConfig logic is something I thought of when @adesrosiers raised this issue, but wouldn't work for non-Android projects. Potentially I could create an Android-specific package to provide version number support. |
I added support for self-managed milestones in version 0.0.3. I still need to investigate an Android-specific solution. I'm not entirely sure that the BuildConfig class is available at the point the annotationProcessor gets run, so it's not a trivial matter. A gradle plugin may be worth looking into. |
Gradle supports annotationProcessorOptions, which allows you to pass arguments from your build.gradle to the annotationProcessor. The information I've found seems to talk about the JACK build chain for Android projects, which not everyone will have moved to by now. I'm going to be away for a week, so I'm leaving this note for myself as a reminder of what I should look at when I return. javaCompileOptions {
annotationProcessorOptions {
arguments = ['versionCode' : 'YOUR_VERSION_HERE']
}
} The GreenRobot EventBus supports such options. |
I got bored on my flight, so I had a quick go at implementing version code support. I've published 0.0.4-SNAPSHOT to the snapshot repository. The code is also available here on Github in the If you're using this library in an Android project then you'll have to add the android {
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
arguments = ["versionCode" : "YOUR_VERSION_CODE_HERE"]
}
}
}
} Support for versionName is a bit more complicated. Some people use semantic versioning (e.g. 3.0.1), which shouldn't be too complicated, but people also use codenames, etc. which makes it very difficult to tell if a specific version is newer or older than another. |
Just pushed version 0.0.4 with support for For Android projects you need to follow the instructions in the README. They're similar to my previous update on this issue, but I'll include a more complete version below for the sake of completeness. android {
defaultConfig {
versionCode 4
versionName "0.4.0"
javaCompileOptions {
annotationProcessorOptions {
arguments = ['versionCode': String.valueOf(defaultConfig.versionCode),
'versionName': defaultConfig.versionName]
}
}
}
} You have to have a versionCode that can be parsed to an Integer, and the versionName has to adhere to the semantic versioning schema. This may not match up with what Android defaults to. If there are problems then I may look to support other versioning schemas, but that complicates things a bit more than I'd like. |
Would be awesome if this supported failing the build when a certain app version is reached:
@RemoveThis(version = "1.0.1")
The text was updated successfully, but these errors were encountered: