-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapiKeysCreator.gradle
97 lines (73 loc) · 4.66 KB
/
apiKeysCreator.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
ext {
fillApiArrays = { variant, fileIsInRoot ->
// logger.info("fillApiArrays: {}", variant.productFlavors[0].name)
def pathToFileWithData
if(fileIsInRoot){
// logger.lifecycle('fileIsInRoot: {}', fileIsInRoot)
pathToFileWithData = "apiKeys.properties"
} else {
// logger.lifecycle('variant.productFlavors[0].name: {}', variant.productFlavors[0].name)
pathToFileWithData = "config/" + variant.productFlavors[0].name + "/apiKeys.properties"
}
fillData(variant, pathToFileWithData)
}
fillData = { variant, pathToFileWithData ->
//add market skus to buildConfig
//there is a way to store it in res... but it's awful
//http://stackoverflow.com/a/41655569/3212712
//Load market SKUs
if (rootProject.file(pathToFileWithData).exists()) {
def marketSkusPropertiesFile = rootProject.file(pathToFileWithData);
def properties = new Properties()
properties.load(new FileInputStream(marketSkusPropertiesFile))
variant.resValue('string', 'yandex_metrica_api_key', properties.get("yandexMetricaApiKey"))
//ads
//admob
variant.resValue('string', 'ads_app_id', properties.get("adMobAppId"))
variant.resValue('string', 'ad_unit_id_interstitial', properties.get("adsBannerIdInterstitial"))
variant.resValue('string', 'ad_unit_id_gallery_banner', properties.get("adsBannerIdGallery"))
variant.resValue('string', 'ad_unit_id_article_screen_banner', properties.get("adsBannerIdArticleScreen"))
variant.resValue('string', 'ad_unit_id_main_screen_banner', properties.get("adsBannerIdMainScreen"))
variant.resValue('string', 'appodeal_app_key', properties.get("appodealAppKey"))
//admob END
//mopub
variant.resValue('string', 'mopub_ad_unit_id_banner', properties.get("mopubBannerId"))
variant.resValue('string', 'mopub_ad_unit_id_interstitial', properties.get("mopubInterstitialId"))
variant.resValue('string', 'mopub_ad_unit_id_rewarded_video', properties.get("mopubRewardedVideoId"))
variant.resValue('string', 'mopub_ad_unit_id_native', properties.get("mopubNativeId"))
//mopub END
//ads END
variant.resValue('integer', 'com_vk_sdk_AppId', properties.get("vkSdkAppId"))
//use string, as so in facebook docs...
variant.resValue('string', 'facebook_app_id', properties.get("facebookAppId"))
variant.resValue('string', 'firebase_db_url', properties.get("firebaseUri"))
//our APIs data
variant.resValue('string', 'tools_api_url', properties.get("vpsApiAddress"))
variant.buildConfigField('String', 'TOOLS_API_URL', '"' + properties.get("vpsApiAddress") + '"')
variant.resValue('string', 'scp_reader_api_url', properties.get("scpReaderApiAddress"))
variant.buildConfigField('String', 'SCP_READER_API_URL', '"' + properties.get("scpReaderApiAddress") + '"')
variant.buildConfigField('String', 'SCP_READER_API_CLIENT_ID', '"' + properties.get("scpReaderApiClientId") + '"')
variant.buildConfigField('String', 'SCP_READER_API_CLIENT_SECRET', '"' + properties.get("scpReaderApiClientSecret") + '"')
variant.buildConfigField('String', 'BANNER_AUTHOR_EMAIL', '"' + properties.get("bannerAuthorEmail") + '"')
//our APIs data END
variant.resValue('string', 'web_application_id', properties.get("webApplicationId"))
variant.resValue('integer', 'realm_version', properties.get("realmVersion"))
variant.resValue('bool', 'filter_by_type_enabled', properties.get("filterByTypeEnabled"))
variant.resValue('bool', 'social_login_vk_enabled', properties.get("socialLoginVkEnabled"))
variant.resValue('bool', 'multiTagSearchEnabled', properties.get("multiTagSearchEnabled"))
variant.resValue('bool', 'siteHasRatedArticlesList', properties.get("siteHasRatedArticlesList"))
} else {
logger.lifecycle('pathToFileWithData: {}', pathToFileWithData)
throw new GradleException("You need to have apiKeys.properties file in projectRoot/config/{FLAVOR_NAME} with " +
"yandexMetricaApiKey," +
"adMobAppId," +
"adsBannerIdInterstitial," +
"vkSdkAppId," +
"firebaseUri," +
"vpsApiAddress" +
"webApplicationId" +
"vpsApiAddress" +
" etc variables to build project")
}
}
}