Skip to content

Latest commit

 

History

History
107 lines (94 loc) · 3.13 KB

readme.md

File metadata and controls

107 lines (94 loc) · 3.13 KB

PorFlavor

Elegant Objects Respected Here Build Status codecov

Gradle plugin version License: MIT

nullfree status staticfree status allfinal status allpublic status setterfree status

What it is?

PorFlavor is the plugin for extending the android product flavors. When you use multiple dimensions you can not define unique build config fields or res values per flavor:

android {
    flavorDimensions 'brand', 'version'
    
    productFlavors {
        Brand1 {
            dimension 'brand'
        }
        Brand2 {
            dimension 'brand'
        }
        Brand3 {
            dimension 'brand'
        }
        Store {
            dimension 'version'
        }
        Staging {
            dimension 'version'
        }
    }
}

and you can not define unique field for Brand2Staging flavors. But with porflavor plugin you can!

Getting started

Add porflavor plugin:

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "gradle.plugin.com.nikialeksey:porflavor-gradle-plugin:<latest>"
  }
}

And then apply it:

apply plugin 'com.android.application'
apply plugin: 'com.nikialeksey.porflavor'

android {
    flavorDimensions 'brand', 'version'
        
    productFlavors {
        Brand1 {
            dimension 'brand'
        }
        Brand2 {
            dimension 'brand'
        }
        Brand3 {
            dimension 'brand'
        }
        Store {
            dimension 'version'
        }
        Staging {
            dimension 'version'
        }
    }
    
    porflavor {
        Brand1Store {
            buildConfigField "boolean", "fooFeatureEnabled", "false"
            resValue "string", "appName", "App"
        }
        Brand1Staging {
            buildConfigField "boolean", "fooFeatureEnabled", "false"
            resValue "string", "appName", "App Staging"
        }
    }
}