Welcome to mirror list, hosted at ThFree Co, Russian Federation.

build.gradle « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0d014cef28e59354b294c81fda7942e772626143 (plain)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
buildscript {
  repositories {
    jcenter()
  }

  dependencies {
    classpath 'com.android.tools.build:gradle:1.2.3'
  }
}

allprojects {
  repositories {
    jcenter()
  }
}

apply plugin: 'com.android.application'

dependencies {
  // android support libs
  compile 'com.android.support:support-v4:22.2.1'
  compile 'com.android.support:appcompat-v7:22.2.1'
  compile 'com.android.support:recyclerview-v7:22.2.1'
  compile 'com.android.support:design:22.2.1'
  // google play services
  compile 'com.google.android.gms:play-services-location:7.5.0'
  compile 'com.google.android.gms:play-services-analytics:7.5.0'
  compile 'com.google.android.gms:play-services-plus:7.5.0'
  // 3-party
  compile 'com.nineoldandroids:library:2.4.0'
  compile 'com.facebook.android:facebook-android-sdk:4.4.0'
  // for Parse SDK
  compile 'com.parse.bolts:bolts-android:1.1.2'
  compile fileTree(dir: '3rd_party', include: '*.jar')
  // BottomSheet
  compile project(":3rd_party:BottomSheet")
}

def getDate() {
  def date = new Date()
  def formattedDate = date.format('yyMMdd')
  return formattedDate
}

android {
  // All properties are read from gradle.properties file
  compileSdkVersion propTargetSdkVersion.toInteger()
  buildToolsVersion propBuildToolsVersion

  defaultConfig {
    // Default package name is taken from the manifest and should be com.mapswithme.maps
    versionCode propVersionCode.toInteger()
    versionName propVersionName
    minSdkVersion propMinSdkVersion.toInteger()
    targetSdkVersion propTargetSdkVersion.toInteger()
    applicationId 'com.mapswithme.maps.pro'
    buildConfigField 'String', 'STATISTICS_URL', propStatisticsUrl
    buildConfigField 'String', 'SUPPORT_MAIL', '"android@maps.me"'
    buildConfigField 'String', 'REVIEW_URL', '"market://details?id=com.mapswithme.maps.pro"'
    buildConfigField 'int', 'RATING_THRESHOLD', '5'
  }

  sourceSets.main {
    manifest.srcFile 'AndroidManifest.xml'
    res.srcDirs = ['res']
    java.srcDirs = ['src', '../3party/Alohalytics/src/android/java']
    // assets folder is auto-generated by tools/android/update_assets.sh, so we keep all static resources in separate folders.
    assets.srcDirs = ['assets']
    jniLibs.srcDirs = ['libs']
  }

  productFlavors {
    google {
      versionName = android.defaultConfig.versionName + '-Google'
      buildConfigField 'String', 'SUPPORT_MAIL', '"googleplay@maps.me"'
    }

    samsung {
      versionName = android.defaultConfig.versionName + '-Samsung'
      buildConfigField 'String', 'REVIEW_URL', '"samsungapps://ProductDetail/com.mapswithme.maps.pro"'
      buildConfigField 'String', 'SUPPORT_MAIL', '"samsung@maps.me"'
      android.sourceSets.samsung.assets.srcDirs = ['flavors/mwm-ttf-assets']
    }

    amazon {
      versionName = android.defaultConfig.versionName + '-Amazon'
      buildConfigField 'String', 'REVIEW_URL', '"amzn://apps/android?p=com.mapswithme.maps.pro"'
      buildConfigField 'String', 'SUPPORT_MAIL', '"amazon@maps.me"'
      buildConfigField 'int', 'RATING_THRESHOLD', '4'
      android.sourceSets.amazon.assets.srcDirs = ['flavors/mwm-ttf-assets']
    }

    yandex {
      versionName = android.defaultConfig.versionName + '-Yandex'
      buildConfigField 'String', 'REVIEW_URL', '"yastore://details?id=com.mapswithme.maps.pro"'
      android.sourceSets.yandex.assets.srcDirs = ['flavors/mwm-ttf-assets']
    }

    preinstall {
      versionName = android.defaultConfig.versionName + '-Preinstall'
      buildConfigField 'String', 'SUPPORT_MAIL', '"googleplay@maps.me"'
    }

    cipherlab {
      versionName = android.defaultConfig.versionName + '-CipherLab'
      android.sourceSets.cipherlab.assets.srcDirs = ['flavors/mwm-ttf-assets']
    }

    xiaomi {
      versionName = android.defaultConfig.versionName + '-Xiaomi'
      buildConfigField 'String', 'REVIEW_URL', '"http://app.mi.com/detail/85835?ref=search"'
      android.sourceSets.xiaomi.assets.srcDirs = ['flavors/mwm-ttf-assets']
    }

    lenovo {
      versionName = android.defaultConfig.versionName + '-Lenovo'
      android.sourceSets.lenovo.assets.srcDirs = ['flavors/mwm-ttf-assets']
    }

    web {
      versionName = android.defaultConfig.versionName + '-Web'
      android.sourceSets.web.assets.srcDirs = ['flavors/mwm-ttf-assets']
    }

    nineApp {
      versionName = android.defaultConfig.versionName + '-9app'
      buildConfigField 'String', 'REVIEW_URL', '"http://www.9apps.com/android-apps/mapswithme-maps-pro/"'
      android.sourceSets.nineApp.assets.srcDirs = ['flavors/mwm-ttf-assets']
    }

    mobogenie {
      versionName = android.defaultConfig.versionName + '-Mobogenie'
      android.sourceSets.mobogenie.assets.srcDirs = ['flavors/mwm-ttf-assets']
    }

    tencent {
      versionName = android.defaultConfig.versionName + '-Tencent'
      android.sourceSets.tencent.assets.srcDirs = ['flavors/mwm-ttf-assets']
      // TODO While store url is unknown, force all rating reviews to be sent to our email.
      // Change it in the next version after publishing app to the store.
      buildConfigField 'int', 'RATING_THRESHOLD', '6'
    }

    baidu {
      versionName = android.defaultConfig.versionName + '-Baidu'
      android.sourceSets.baidu.assets.srcDirs = ['flavors/mwm-ttf-assets']
      // TODO While store url is unknown, force all rating reviews to be sent to our email.
      // Change it in the next version after publishing app to the store.
      buildConfigField 'int', 'RATING_THRESHOLD', '6'
    }

    appChina {
      versionName = android.defaultConfig.versionName + '-AppChina'
      android.sourceSets.appChina.assets.srcDirs = ['flavors/mwm-ttf-assets']
      // TODO While store url is unknown, force all rating reviews to be sent to our email.
      // Change it in the next version after publishing app to the store.
      buildConfigField 'int', 'RATING_THRESHOLD', '6'
    }
  }

  // Currently (as of 1.2.3 gradle plugin) ABI filters aren't supported inside of product flavors, so we cannot generate splitted builds only for Google build.
  // TODO check that feature when new gradle plugins will appear
  // connected bugreport https://code.google.com/p/android/issues/detail?id=178606
  splits {
    abi {
      enable true
      reset()
      include 'x86', 'armeabi-v7a'
      universalApk true
    }
  }

  // TODO: Fix a lot of lint errors in our code
  lintOptions {
    abortOnError false
  }

  gradle.projectsEvaluated {
    android.applicationVariants.all { variant ->
      def task = variant.name.capitalize()
      def runTask = "run$task"
      def installTask = "install$task"
      project.task(type: Exec, "${runTask}", dependsOn: "${installTask}") {
        def component = "$applicationId/com.mapswithme.maps.DownloadResourcesActivity"
        executable "sh"
        args "-c", "adb shell am start -n ${component}"
      }
    }
  }

  signingConfigs {
    mapswithme {
      storeFile file('../tools/android/mapswithme.keystore')
      storePassword '***REMOVED***'
      keyAlias 'mapswithme'
      keyPassword '***REMOVED***'
    }

    yopme {
      storeFile file('YopMe/key/android.keystore')
      storePassword '***REMOVED***'
      keyAlias 'yopme'
      keyPassword '***REMOVED***'
    }
  }

  buildTypes {
    debug {
      applicationIdSuffix '.debug'   // Allows to install debug and release builds together
      versionNameSuffix '-debug'
      jniDebuggable true           // Enable jni debug build
      zipAlignEnabled true
      android.sourceSets.debug.setRoot('flavors/debug')
    }

    release {
      signingConfig signingConfigs.mapswithme
      minifyEnabled true
      shrinkResources true
      proguardFile('proguard-mwm.txt')
    }

    beta {
      applicationIdSuffix '.beta'
      versionNameSuffix '-beta'
      signingConfig signingConfigs.mapswithme
      android.sourceSets.beta.setRoot('flavors/beta')
    }
  }

  // We don't compress these extensions in assets/ because our random FileReader can't read zip-compressed files from apk
  aaptOptions {
    noCompress 'txt', 'bin', 'skn', 'html', 'png', 'json', 'mwm', 'ttf'
    ignoreAssetsPattern "!.svn:!.git:!.DS_Store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"
  }

  // Enables new Java features in KitKat+ but needs Java 1.7 installed
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
  }
}

import com.android.build.OutputFile
project.ext.versionCodes = ['armeabi-v7a':1, 'x86':2]

android.applicationVariants.all { variant ->
  variant.outputs.each { output ->
    if (output.outputFile != null && output.outputFile.name.endsWith('.apk')) {
      def file = output.outputFile
      // version at the end of each built apk
      output.outputFile = new File(file.parent, file.name.replace(".apk", "-" + android.defaultConfig.versionName + "-" + getDate() + ".apk"))
      // set different versionCodes for different ABIs
      int abiVersionCode = project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) ?: 0
      output.versionCodeOverride = (abiVersionCode * 1000) + android.defaultConfig.versionCode
    }
  }
}

//@{ Below are tasks needed to compile our NDK part
apply plugin: 'base'

task cppLibsBuildDebug(type: Exec, description: 'Building DEBUG version of static C++ libraries') {
  commandLine 'bash', '../tools/autobuild/android.sh', 'debug'
}

task cppLibsBuildRelease(type: Exec, description: 'Building RELEASE/PRODUCTION version of static C++ libraries') {
  commandLine 'bash', '../tools/autobuild/android.sh', 'production'
}

def NUM_OF_PARALLEL_MAKE_TASKS = Runtime.runtime.availableProcessors() + 1
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def NDK_BUILD = properties.getProperty('ndk.dir') + '/ndk-build'

task ndkBuildDebug(type: Exec, dependsOn: 'cppLibsBuildDebug', description: 'Building DEBUG jni sources') {
  def clArgs = ([NDK_BUILD, '-j' + NUM_OF_PARALLEL_MAKE_TASKS] + propDebugNdkFlags.split(' ')).flatten()
  commandLine clArgs
}

task ndkBuildRelease(type: Exec, dependsOn: 'cppLibsBuildRelease', description: 'Building RELEASE/PRODUCTION jni sources') {
  def clArgs = ([NDK_BUILD, '-j' + NUM_OF_PARALLEL_MAKE_TASKS] + propReleaseNdkFlags.split(' ')).flatten()
  commandLine clArgs
}

task ndkBuildClean(type: Exec, description: 'Clean native libraries') {
  commandLine NDK_BUILD, 'clean'
}

tasks.withType(JavaCompile) { compileTask ->
  if (compileTask.name.contains('Release') || compileTask.name.contains('Beta')) {
    compileTask.dependsOn ndkBuildRelease
  } else {
    compileTask.dependsOn ndkBuildDebug
  }
}

clean.dependsOn 'ndkBuildClean'