Skip to content

PorFlavor - is the gradle plugin for extending android productFlavors

License

Notifications You must be signed in to change notification settings

JonatanPlesko/porflavor

 
 

Repository files navigation

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?

ProFlavor 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"
        }
    }
}

About

PorFlavor - is the gradle plugin for extending android productFlavors

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%