Created
February 27, 2018 19:47
-
-
Save Bramengton/38fc24ef432878d0084c1f74953e49e4 to your computer and use it in GitHub Desktop.
Customize on dev app for any brands..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.application' | |
@Nullable | |
def getProperties(String fileName) { | |
final Properties properties = new Properties() | |
def file = file(fileName) | |
if (file.exists()) { | |
file.withInputStream { stream -> properties.load(stream) } | |
} | |
return properties | |
} | |
static def getProperty(@Nullable Properties properties, String name) { | |
return properties.getProperty(name) ?: "$name missing" | |
} | |
android { | |
compileSdkVersion 25 | |
buildToolsVersion '25.0.3' | |
defaultConfig { | |
applicationId "io.brmtn.flavors" | |
minSdkVersion 11 | |
targetSdkVersion 23 | |
versionCode 1 | |
versionName "1.0" | |
} | |
lintOptions { | |
ignore 'ExtraTranslation', 'MissingTranslation' | |
abortOnError false | |
} | |
signingConfigs { | |
release { | |
def toolsPath = projectDir.getParent() + "/tools/" | |
try { | |
Properties properties = getProperties(toolsPath + "app.properties") | |
storeFile file(toolsPath + getProperty(properties, 'KEY_FILE')) | |
keyAlias getProperty(properties, 'KEY_ALIAS') | |
storePassword getProperty(properties, 'KEYSTORE_PASSWORD') | |
keyPassword getProperty(properties, 'KEY_PASSWORD') | |
} | |
catch (ex) { | |
throw new InvalidUserDataException("You should define KEYSTORE_PASSWORD and KEY_PASSWORD in stored properties.") | |
} | |
} | |
} | |
buildTypes { | |
debug{ | |
minifyEnabled false | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
} | |
release { | |
minifyEnabled false | |
proguardFiles = buildTypes.debug.proguardFiles | |
signingConfig signingConfigs.release | |
} | |
} | |
/* | |
* | |
* buildConfigField "int", "MAX_RETRIES", "3" | |
* buildConfigField "String", "SERVER_URL", "\"http://dev.myserver.com\"" | |
* buildConfigField "boolean", "STAGE_ONLY_THING", "true" | |
* | |
* manifestPlaceholders = [ appLabel: "@string/app_name" ] | |
* AndroidManifest.xml -> android:label="${appLabel}" | |
* | |
* */ | |
productFlavors { | |
develop_ { | |
manifestPlaceholders = [ appLabel: "@string/app_name" ] | |
buildConfigField "String", "SERVER_URL", "\"http://dev.myserver.com\"" | |
buildConfigField "boolean", "STAGE_ONLY_THING", "true" | |
} | |
brand1_ { | |
applicationId "com.brand.one" | |
buildConfigField "String", "SERVER_URL", "\"http://brand.one.com\"" | |
buildConfigField "boolean", "STAGE_ONLY_THING", "true" | |
manifestPlaceholders = [ appLabel: "Brand Name1" ] | |
} | |
brand2_ { | |
applicationId "com.brand.two" | |
buildConfigField "String", "SERVER_URL", "\"http://brand.two.com\"" | |
buildConfigField "boolean", "STAGE_ONLY_THING", "true" | |
manifestPlaceholders = [ appLabel: "Brand Name2" ] | |
} | |
brand3_ { | |
applicationId "com.brand.tree" | |
buildConfigField "String", "SERVER_URL", "\"http://brand.tree.com\"" | |
buildConfigField "boolean", "STAGE_ONLY_THING", "true" | |
manifestPlaceholders = [ appLabel: "Brand Name3" ] | |
} | |
} | |
} | |
dependencies { | |
compile 'com.android.support:appcompat-v7:25.3.1' | |
compile 'com.android.support.constraint:constraint-layout:1.0.2' | |
compile 'com.android.support:design:25.3.1' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Как проверить все доступные варианты сборок:
gradlew tasks
Как собрать все варианты сборк одновременно:
gradlew assemble
Как собрать конкретный билд:
gradlew assembleBrand1_
Дополнительно для gradlew: