zafarkhaja / jsemver

Java implementation of the SemVer Specification
MIT License
429 stars 82 forks source link

Access version parts of semantic version #43

Closed schmitzhermes closed 1 year ago

schmitzhermes commented 6 years ago

Hey, this is probably rather a question than an issue, but I did not figure it out yet. In an Android app I use the following paradigm to create a versionCode: https://medium.com/@manas/manage-your-android-app-s-versioncode-versionname-with-gradle-7f9c5dcf09bf

In order to make that calculation provided in the link, I need to access the version parts as integers. I know that this is possible with this com.github.zafarkhaja.semver.Version class, but I could not figure out how to access this from the gradle build script.

So I need something like this:

android {
  defaultConfig {
    applicationId “something.app”
    versionCode scmVersion.version.major * 10000 
                + scmVersion.version.minor * 100 
                + scmVersion.version.patch
    versionName scmVersion.version
  }
}

Can you help me out here? I'd rather not parse the version string and split it in parts myself :-)

Thank you guys

zafarkhaja commented 1 year ago

Hello @schmitzhermes! Sorry it took me this long to get back to you.

If by some chance it's relevant to you, you can try the following

version.majorVersion
version.minorVersion
version.patchVersion