build.gradle.kts 3.7 KB

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