build.gradle.kts 3.9 KB

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