gtcompscientist / whitelabel

A gradle plugin for quickly creating white labeled apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

whitelabel

Gradle plugin for quickly creating white labeled apps without muddying your Android project folders

Build Status: CircleCI

Quick Start Guide

  1. Include the Gradle plugin repository in buildscript repositories (see Buildscript).
  2. Add plugin to buildscript dependencies.
  3. Apply the plugin (see Usage).
  4. Configure each specific white label flavor (see Flavor Setup)
  5. [Optional] Configure the plugin options (see Plugin Options)

Buildscript

Add to your buildscript dependencies (top-level build.gradle file):

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    // ... Other dependencies
    classpath "gradle.plugin.co.csadev.whitelabel:whitelabel:0.6"
  }
}

Usage

Apply it to the bottom of your app-level build.gradle file as following below.

If you use the Google Services plugin, apply above that line

apply plugin: 'co.csadev.whitelabel'
apply plugin: 'com.google.gms.google-services'

The plugin doesn't explicitly create any tasks. It simply adds the flavors specified within your existing tasks.

Configuration

Coming soon. Right now the ability to properly inject a flavor dimension and the white label flavors precludes normal configuration blocks. This is a TODO.

Flavor Setup

Each flavor can have any or all of the following configuration files and folder:

- [app]
  |
  + - [whitelabel]
      |
      + - [flavorName]
          |
          + - [java]
          |
          + - [res]
          |
          + - [renderscript]
          |
          + - [aidl]
          |
          + - [shaders]
          |
          + - [jni]
          |
          + - [jniLibs]
          |
          + - buildConfig
          |
          + - manifestPlaceholders
          |
          + - applicationIdSuffix

Folders are all designed to be added to the sourceSets in the same way that you would add them normally.

buildConfig

Text file (no extension) to add BuildConfig fields as you would normally do within your app's build.gradle

Add one config per line, with the same order and escaping as you would normally include in your build.gradle, without comma separation, and without escaped quotes.

Before:

buildConfigField "String", "ConfigString", "\"ConfiguredFromGradleFlavor\""

After:

String ConfigString "ConfiguredFromGradleFlavor"

manifestPlaceholders

Text file (no extension) to include Manifest Placeholder fields as you would normally do within your app's build.gradle

Add one config per line, with the same order and escaping as you would normally include in your build.gradle, without comma separation, and without quotes.

Before:

manifestPlaceholders.put("manifest_string", "configured From Gradle")

After:

manifest_string configured From Gradle

Quotes are excluded to ease the parsing of this file.

applicationIdSuffix

Text file (no extension) to override the folder name as the applicationIdSuffix for the flavor

Only one line is read, with no quotes, or spaces allowed

Before:

applicationIdSuffix ".flavorSuffix"

After:

flavorSuffix

Plugin Options

An optional JSON file in your application root directory named "whitelabel.json" will allow you to configure certain options in the plugin:

  • root: Directory location for whitelabel configuration
  • dimensionPosition: Where within the flavorDimensions to place the whitelabel (Default is "0", first)
  • addApplicationSuffix: Whether to include the application suffix

The json structure is actually an array of these objects, so that multiple dimensions can be configured. If more than one is provided, the list will be sorted by the dimensionPosition so that the flavorDimension array order is maintained.

[
  {
    "root":"src/test/fixtures/config_app/configuredLabel",
    "dimensionPosition":0,
    "addApplicationSuffix":false
  },
  {
    "root":"src/test/fixtures/config_app/secondaryLabel",
    "dimensionPosition":1,
    "addApplicationSuffix":true
  }
]

About

A gradle plugin for quickly creating white labeled apps

License:Apache License 2.0


Languages

Language:Kotlin 100.0%