build.gradle.kts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. plugins {
  2. id("com.android.application")
  3. id("kotlin-android")
  4. id("kotlin-android-extensions")
  5. }
  6. androidExtensions {
  7. isExperimental = true
  8. }
  9. android {
  10. compileSdkVersion(29)
  11. buildToolsVersion("29.0.3")
  12. defaultConfig {
  13. applicationId = "com.sirekanyan.knigopis"
  14. minSdkVersion(21)
  15. targetSdkVersion(29)
  16. versionCode = 31
  17. versionName = "0.3.4"
  18. setProperty("archivesBaseName", "$applicationId-$versionName-$versionCode")
  19. manifestPlaceholders = mapOf(
  20. "LOGIN_CALLBACK_SCHEME" to "e270636c0efc6cad95130113d3bbafc3",
  21. "LOGIN_CALLBACK_HOST" to "532b8e7fc54c52b6df5b55181acc241a",
  22. "LOGIN_CALLBACK_PATH" to "$versionCode"
  23. )
  24. manifestPlaceholders.forEach { (key, value) ->
  25. buildConfigField("String", key, "\"$value\"")
  26. }
  27. vectorDrawables.useSupportLibrary = true
  28. }
  29. buildTypes {
  30. getByName("release") {
  31. isMinifyEnabled = true
  32. isShrinkResources = true
  33. proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard")
  34. }
  35. getByName("debug") {
  36. applicationIdSuffix = ".debug"
  37. }
  38. }
  39. compileOptions {
  40. sourceCompatibility = JavaVersion.VERSION_1_8
  41. targetCompatibility = JavaVersion.VERSION_1_8
  42. }
  43. }
  44. dependencies {
  45. // kotlin standard library
  46. implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72")
  47. // androidx libraries
  48. implementation("androidx.appcompat:appcompat:1.1.0")
  49. implementation("androidx.constraintlayout:constraintlayout:1.1.3")
  50. implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
  51. implementation("androidx.browser:browser:1.2.0")
  52. // rxjava
  53. implementation("io.reactivex.rxjava2:rxjava:2.2.19")
  54. implementation("io.reactivex.rxjava2:rxkotlin:2.4.0")
  55. implementation("io.reactivex.rxjava2:rxandroid:2.1.1")
  56. // retrofit
  57. implementation("com.squareup.retrofit2:retrofit:2.9.0")
  58. implementation("com.squareup.retrofit2:adapter-rxjava2:2.9.0")
  59. implementation("com.squareup.retrofit2:converter-gson:2.9.0")
  60. // okhttp
  61. @Suppress("GradleDependency")
  62. implementation("com.squareup.okhttp3:logging-interceptor:3.14.9")
  63. // etc
  64. implementation("com.google.android.material:material:1.1.0")
  65. implementation("com.github.bumptech.glide:glide:4.11.0")
  66. // crash reporting
  67. implementation("ch.acra:acra-http:5.1.3")
  68. }
  69. task("updateReadme") {
  70. dependsOn("assembleRelease")
  71. doLast {
  72. val releaseVariant = android.applicationVariants.first { it.name == "release" }
  73. val releaseFiles = releaseVariant.outputs.map { it.outputFile }
  74. val apkFile = releaseFiles.single { it.exists() && it.extension == "apk" }
  75. val properties = mapOf(
  76. "apkSize" to "%.2f".format(apkFile.length().toFloat() / 1024 / 1024),
  77. "appVersion" to android.defaultConfig.versionName.orEmpty(),
  78. "appPackage" to android.defaultConfig.applicationId.orEmpty(),
  79. "minSdkVersion" to android.defaultConfig.minSdkVersion?.apiLevel?.toString().orEmpty()
  80. )
  81. rootProject.file("README.md").printWriter().use { readme ->
  82. rootProject.file("readme.md").forEachLine { inputLine ->
  83. readme.appendln(
  84. properties.entries.fold(inputLine) { line, (key, value) ->
  85. line.replace("{{$key}}", value)
  86. }
  87. )
  88. }
  89. }
  90. }
  91. }