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

Different format per buildType? #86

Open
fejd opened this issue Oct 15, 2020 · 2 comments
Open

Different format per buildType? #86

fejd opened this issue Oct 15, 2020 · 2 comments

Comments

@fejd
Copy link

fejd commented Oct 15, 2020

Is it possible to use different version formats for release and debug? For example, for debug builds I'd like to include the commit hash, but omit it for release.

I was able to work around this by stripping parts of the string in when handling the release variant, but maybe there's a simpler way to do it with the plugin:

androidGitVersion {
    codeFormat 'MMNNBBB'
    commitHashLength = 4
    format '%tag%%.count%%-commit%'
    untrackedIsDirty = false
}

android.applicationVariants.all { variant ->
    if (variant.buildType.name == "release") {
        variant.outputs.each { output ->
            output.versionCodeOverride = androidGitVersion.code()
            output.versionNameOverride = stripVersionNameForRelease(androidGitVersion.name())
        }
    }
}

static def stripVersionNameForRelease(String versionName) {
    return versionName.substring(0, versionName.indexOf("-"))
}
@gladed
Copy link
Collaborator

gladed commented Oct 15, 2020

What you're doing is the only way right now. But having totally separate formats for "release" branches is a great idea. Instead of hideBranches, we could have releaseBranches and releaseFormat.

@ivanbartsov
Copy link

@ghost
https://github.com/ReactiveCircus/app-versioning#custom-rules
Here's an alternate approach to the same problem from another project -- allow overriding the plugin's config per build variant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants