build.gradle.kts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. compileSdk = 31
  11. defaultConfig {
  12. applicationId = "com.sirekanyan.knigopis"
  13. minSdk = 21
  14. targetSdk = 31
  15. versionCode = 32
  16. versionName = "1.0.0"
  17. setProperty("archivesBaseName", "$applicationId-$versionName-$versionCode")
  18. manifestPlaceholders["LOGIN_CALLBACK_SCHEME"] = "e270636c0efc6cad95130113d3bbafc3"
  19. manifestPlaceholders["LOGIN_CALLBACK_HOST"] = "532b8e7fc54c52b6df5b55181acc241a"
  20. manifestPlaceholders["LOGIN_CALLBACK_PATH"] = "$versionCode"
  21. manifestPlaceholders.forEach { (key, value) ->
  22. buildConfigField("String", key, "\"$value\"")
  23. }
  24. vectorDrawables.useSupportLibrary = true
  25. }
  26. buildTypes {
  27. getByName("release") {
  28. isMinifyEnabled = true
  29. isShrinkResources = true
  30. proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard")
  31. }
  32. getByName("debug") {
  33. applicationIdSuffix = ".debug"
  34. }
  35. }
  36. compileOptions {
  37. sourceCompatibility = JavaVersion.VERSION_1_8
  38. targetCompatibility = JavaVersion.VERSION_1_8
  39. }
  40. }
  41. dependencies {
  42. // androidx libraries
  43. implementation("androidx.appcompat:appcompat:1.4.0")
  44. implementation("androidx.constraintlayout:constraintlayout:2.1.2")
  45. implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
  46. implementation("androidx.browser:browser:1.4.0")
  47. // rxjava
  48. implementation("io.reactivex.rxjava2:rxjava:2.2.21")
  49. implementation("io.reactivex.rxjava2:rxkotlin:2.4.0")
  50. implementation("io.reactivex.rxjava2:rxandroid:2.1.1")
  51. // retrofit
  52. implementation("com.squareup.retrofit2:retrofit:2.9.0")
  53. implementation("com.squareup.retrofit2:adapter-rxjava2:2.9.0")
  54. implementation("com.squareup.retrofit2:converter-gson:2.9.0")
  55. // okhttp
  56. @Suppress("GradleDependency")
  57. implementation("com.squareup.okhttp3:logging-interceptor:3.14.9")
  58. // etc
  59. implementation("com.google.android.material:material:1.4.0")
  60. implementation("com.github.bumptech.glide:glide:4.12.0")
  61. // crash reporting
  62. implementation("ch.acra:acra-http:5.8.4")
  63. }
  64. task("updateReadme") {
  65. dependsOn("assembleRelease")
  66. doLast {
  67. val releaseVariant = android.applicationVariants.first { it.name == "release" }
  68. val releaseFiles = releaseVariant.outputs.map { it.outputFile }
  69. val apkFile = releaseFiles.single { it.exists() && it.extension == "apk" }
  70. val defaultConfig = android.defaultConfig
  71. val properties = mapOf(
  72. "apkSize" to "%.2f".format(apkFile.length().toFloat() / 1024 / 1024),
  73. "applicationId" to defaultConfig.applicationId,
  74. "versionName" to defaultConfig.versionName,
  75. "versionCode" to defaultConfig.versionCode?.toString(),
  76. "minSdkVersion" to defaultConfig.minSdkVersion?.apiLevel?.toString(),
  77. "targetSdkVersion" to defaultConfig.targetSdkVersion?.apiLevel?.toString(),
  78. "repository" to "sirekanyan/knigopis"
  79. )
  80. properties.forEach { (key, value) ->
  81. if (value.isNullOrBlank()) {
  82. logger.warn("Readme property '$key' is empty")
  83. }
  84. }
  85. rootProject.file("README.md").printWriter().use { readme ->
  86. rootProject.file("readme.md").forEachLine { inputLine ->
  87. readme.appendLine(
  88. properties.entries.fold(inputLine) { line, (key, value) ->
  89. line.replace("{{$key}}", value.orEmpty())
  90. }
  91. )
  92. }
  93. }
  94. }
  95. }