From 3e3d818fe6ced9d15ea6962f54b73841fe12c1ca Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Thu, 15 Sep 2016 00:44:35 -0700 Subject: [PATCH] Move some build config fields to AndroidTarget --- .../okbuilds/core/model/AndroidAppTarget.groovy | 7 ------- .../okbuilds/core/model/AndroidTarget.groovy | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/buildSrc/src/main/groovy/com/github/okbuilds/core/model/AndroidAppTarget.groovy b/buildSrc/src/main/groovy/com/github/okbuilds/core/model/AndroidAppTarget.groovy index cbffd4080..a9a5b8ccc 100644 --- a/buildSrc/src/main/groovy/com/github/okbuilds/core/model/AndroidAppTarget.groovy +++ b/buildSrc/src/main/groovy/com/github/okbuilds/core/model/AndroidAppTarget.groovy @@ -72,13 +72,6 @@ class AndroidAppTarget extends AndroidLibTarget { List getBuildConfigFields() { List buildConfig = super.getBuildConfigFields() buildConfig.add("String APPLICATION_ID = \"${applicationId + applicationIdSuffix}\"") - if (versionCode != null) { - buildConfig.add("int VERSION_CODE = ${versionCode}") - } - if (versionName != null) { - buildConfig.add("String VERSION_NAME = \"${versionName}\"") - } - return buildConfig } diff --git a/buildSrc/src/main/groovy/com/github/okbuilds/core/model/AndroidTarget.groovy b/buildSrc/src/main/groovy/com/github/okbuilds/core/model/AndroidTarget.groovy index 4e3737261..aa3023737 100644 --- a/buildSrc/src/main/groovy/com/github/okbuilds/core/model/AndroidTarget.groovy +++ b/buildSrc/src/main/groovy/com/github/okbuilds/core/model/AndroidTarget.groovy @@ -131,12 +131,22 @@ abstract class AndroidTarget extends JavaLibTarget { } List getBuildConfigFields() { - return ["String BUILD_TYPE = \"${buildType}\"", - "String FLAVOR = \"${flavor}\"", - ] + baseVariant.mergedFlavor.buildConfigFields.collect { + List buildConfig = [ + "String BUILD_TYPE = \"${buildType}\"", + "String FLAVOR = \"${flavor}\"", + ] + if (versionCode != null) { + buildConfig.add("int VERSION_CODE = ${versionCode}") + } + if (versionName != null) { + buildConfig.add("String VERSION_NAME = \"${versionName}\"") + } + buildConfig += baseVariant.mergedFlavor.buildConfigFields.collect { String key, ClassField classField -> "${classField.type} ${key} = ${classField.value}" } + + return buildConfig } String getFlavor() {