Ed Holloway-George
Ed Holloway-George

Reputation: 5149

Gradle Advanced Build Plugin not changing version numbers

I stumbled across the Gradle Advanced Build Version Plugin today, but have not been able to get it working. The version of my app after compiling a debug build to my phone seems to remain 0. I have created a version.properties file in the project root as the documentation suggested.

My project's build.gradle file contains:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
        classpath 'org.moallemi.gradle.advanced-build-version:gradle-plugin:1.5.0'
    }
}

and app/build.gradle contains

apply plugin: 'org.moallemi.advanced-build-version'

advancedVersioning {
    codeOptions {
        versionCodeType org.moallemi.gradle.internal.VersionCodeType.AUTO_INCREMENT_ONE_STEP
        dependsOnTasks 'debug', 'release', 'assemble'
    }
    outputOptions {
        renameOutput true
        nameFormat '$flavorName-$buildType-$versionName'
    }
}

...

android {
   ...
    defaultConfig {
       ...
        versionCode advancedVersioning.versionCode
        versionName advancedVersioning.versionName
    }

Has anyone got any pointers in where I might be going wrong or experience using it?

As far as I am aware that should work when running as I run a debug build?

Upvotes: 1

Views: 1093

Answers (1)

Ed Holloway-George
Ed Holloway-George

Reputation: 5149

The version was showing incorrectly as it has to be explicitly specified in the nameOptions

apply plugin: 'org.moallemi.advanced-build-version'

advancedVersioning {
    nameOptions {
        versionMajor 1
        versionMinor 0
        versionPatch 0
        versionBuild versionCode
    }
    codeOptions {
        versionCodeType org.moallemi.gradle.internal.VersionCodeType.AUTO_INCREMENT_ONE_STEP
        dependsOnTasks 'debug', 'release', 'assemble'
    }
    outputOptions {
        renameOutput true
        nameFormat '$flavorName-$buildType-$versionName'
    }
}

Upvotes: 1

Related Questions