build.gradle 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // flutter
  2. def localProperties = new Properties()
  3. def localPropertiesFile = rootProject.file('local.properties')
  4. if (localPropertiesFile.exists()) {
  5. localPropertiesFile.withInputStream { stream ->
  6. localProperties.load(stream)
  7. }
  8. }
  9. def flutterRoot = localProperties.getProperty('flutter.sdk')
  10. if (flutterRoot == null) {
  11. throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
  12. }
  13. apply plugin: 'com.android.application'
  14. apply plugin: 'kotlin-android'
  15. apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
  16. flutter {
  17. source '../..'
  18. }
  19. // build versioning
  20. def currentVersionCode() {
  21. def propsFile = file('versions.properties')
  22. def props = new Properties()
  23. props.load(new FileInputStream(propsFile))
  24. return props['build.versionCode'].toInteger()
  25. }
  26. def incrementVersionCode() {
  27. def propsFile = file('versions.properties')
  28. def props = new Properties()
  29. props.load(new FileInputStream(propsFile))
  30. def currentCode = props['build.versionCode'].toInteger()
  31. def nextCode = currentCode + 1
  32. props['build.versionCode'] = nextCode.toString()
  33. props.store(propsFile.newWriter(), null)
  34. return nextCode
  35. }
  36. // increments build version code on release builds
  37. task('incrementVersionCode') << {
  38. incrementVersionCode()
  39. }
  40. tasks.whenTaskAdded { task ->
  41. if (task.name == 'assembleRelease') {
  42. task.dependsOn 'incrementVersionCode'
  43. }
  44. }
  45. buildscript {
  46. // application variables
  47. ext.app_ver_name = "1.0"
  48. // google version codes
  49. ext.build_tools_ver = '25.0.3'
  50. ext.support_lib_ver = '25.3.1'
  51. ext.google_play_ver = '10.2.4'
  52. ext.constraint_layout_ver = '1.0.2'
  53. }
  54. android {
  55. compileSdkVersion 25
  56. buildToolsVersion "$build_tools_ver"
  57. defaultConfig {
  58. minSdkVersion 19
  59. targetSdkVersion 25
  60. applicationId "com.goposse.routersample"
  61. versionCode currentVersionCode()
  62. versionName "$app_ver_name"
  63. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  64. }
  65. lintOptions {
  66. disable 'InvalidPackage'
  67. }
  68. buildTypes {
  69. release {
  70. // TODO: Add your own signing config for the release build.
  71. // Signing with the debug keys for now, so `flutter run --release` works.
  72. signingConfig signingConfigs.debug
  73. }
  74. }
  75. }
  76. dependencies {
  77. compile fileTree(dir: 'libs', include: ['*.jar'])
  78. // google
  79. compile "com.android.support:appcompat-v7:$support_lib_ver"
  80. compile "com.android.support:support-v13:$support_lib_ver"
  81. compile "com.android.support:support-v4:$support_lib_ver"
  82. // testing
  83. androidTestCompile "com.android.support:support-annotations:$support_lib_ver"
  84. androidTestCompile 'com.android.support.test:runner:0.5'
  85. androidTestCompile 'com.android.support.test:rules:0.5'
  86. compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
  87. }