Skip to content

Allow different configurations per product flavorΒ #2

@jenzz

Description

@jenzz

Ideally following the style of the android closure allowing to override less specific configs, for example:

android {

  ...

    defaultConfig {
        applicationId 'com.jenzz.buildconstants.sample'
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName '1.0.0'
  }

  flavorDimensions 'abi', 'version'

  productFlavors {
    free {
      dimension 'version'
    }
    pro {
      dimension 'version'
    }
    arm {
      dimension "abi"
    }
    mips {
      dimension "abi"
    }
    x86 {
      dimension "abi"
    }
  }
}

buildConstants {

    defaultConfig {
        fileNames {
            java 'SampleBuildConstants'
            xml 'sample_build_constants'
        }
        constants {
            aString = 'string'
        }
    }

    // overrides defaultConfig
    freeDebug {
        fileNames {
            java 'SampleBuildConstants2'
            xml 'sample_build_constants_2'
        }
        constants {
            aString = 'string_two'
        }
    }

    // overrides freeDebug
    armFreeDebug {
        fileNames {
            java 'BuildConstantsFlavor3'
            xml 'build_constants_flavor3'
        }
        constants {
            aString = 'string_three'
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions