Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Latest commit

 

History

History
97 lines (77 loc) · 3.63 KB

migrating-from-old-plugin.md

File metadata and controls

97 lines (77 loc) · 3.63 KB

Migrating from the old plugin

This plugin used to be called com.novoda:build-properties-plugin. If you are using such an old version, you will likely need to perform a migration since there have been several breaking changes in the intervening releases.

You'll also notice that the versioning has been restarted from 0.1, so that the older plugin's version may actually look newer than the ones we have right now. For example, you may be using com.novoda:build-properties-plugin:1.2.1, but that is older than com.novoda:gradle-build-properties-plugin:0.3.

This guide will help you migrate off of the old plugin and onto the new one.

Step 1: change the plugin ID

The plugin identifier has changed from com.novoda:build-properties-plugin to com.novoda:gradle-build-properties-plugin. Check what the latest version is on the releases tab.

This is basically the same first step as if you were adding the plugin from scratch to your project. The readme contains more information on how to add the plugin to your Gradle build.

Don't forget to remove or update any leftover references to the old plugin name.

Step 2: update the buildProperties closure

In the buildProperties closure you need to replace all the file references to using:

buildProperties {
    // Old version:
    application.file rootProject.file('properties/application.properties')

    // Will become:
    application.using rootProject.file('properties/application.properties')
}

If you're using environmental variables as fallback via the built-in env property, you'll notice that it does not exist anymore. To keep using it, you'll need to add it explicitly to your buildProperties:

buildProperties {
    env.using System.getenv()
}

Step 3: switch the resValueProperty usages to the typed alternatives

If you use the resValueProperty to set Android resource values, you'll notice it's not available anymore. Not to despair, it's only been replaced by typed alternatives:

Resource type Replace resValueProperty with
boolean resValueBoolean
int resValueInt
string resValueString

Step 4: switch the buildConfigProperty usages to the typed alternatives

If you use the buildConfigProperty to set Android BuildConfig fields, you'll notice it's not available anymore. Not to despair, it's only been replaced by typed alternatives:

BuildConfig field type Replace buildConfigProperty with
boolean buildConfigBoolean
double buildConfigDouble
int buildConfigInt
long buildConfigLong
String buildConfigString

Step 5: fix signingConfigs

While you could once do:

signingConfigs {
    release {
        signingConfigProperties buildProperties.releaseSigningConfig
    }
}

Now that is not possible anymore. The feature has been dropped as it was not flexible enough. Luckily it is rather easy to bring back. Firstly, add this helper to your android closure:

signingConfigs.all { signingConfig ->
    signingConfig.ext.from = { buildProperties ->
        signingConfig.storeFile teamPropsFile(buildProperties['storeFile'].string)
        signingConfig.storePassword buildProperties['storePassword'].string
        signingConfig.keyAlias buildProperties['keyAlias'].string
        signingConfig.keyPassword buildProperties['keyPassword'].string
    }
}

Then edit your signingConfigs closure to use the from method instead:

signingConfigs {
    release.from releaseSigningConfig
}