build.gradle.kts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 = 33
  11. defaultConfig {
  12. applicationId = "com.sirekanyan.knigopis"
  13. minSdk = 21
  14. targetSdk = 33
  15. versionCode = (property("appVersionCode") as String).toInt()
  16. versionName = property("appVersionName") as String
  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. kotlinOptions {
  41. allWarningsAsErrors = true
  42. }
  43. lint {
  44. warningsAsErrors = true
  45. }
  46. }
  47. dependencies {
  48. // androidx libraries
  49. implementation("androidx.appcompat:appcompat:1.5.1")
  50. implementation("androidx.constraintlayout:constraintlayout:2.1.4")
  51. implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
  52. implementation("androidx.browser:browser:1.4.0")
  53. // rxjava
  54. implementation("io.reactivex.rxjava2:rxjava:2.2.21")
  55. implementation("io.reactivex.rxjava2:rxkotlin:2.4.0")
  56. implementation("io.reactivex.rxjava2:rxandroid:2.1.1")
  57. // retrofit
  58. implementation("com.squareup.retrofit2:retrofit:2.9.0")
  59. implementation("com.squareup.retrofit2:adapter-rxjava2:2.9.0")
  60. implementation("com.squareup.retrofit2:converter-gson:2.9.0")
  61. // okhttp
  62. @Suppress("GradleDependency")
  63. implementation("com.squareup.okhttp3:logging-interceptor:3.14.9")
  64. // etc
  65. implementation("com.google.android.material:material:1.6.1")
  66. implementation("com.github.bumptech.glide:glide:4.14.1")
  67. // crash reporting
  68. implementation("ch.acra:acra-http:5.9.6")
  69. }
  70. task("updateReadme") {
  71. dependsOn("assembleRelease")
  72. doLast {
  73. val releaseVariant = android.applicationVariants.first { it.name == "release" }
  74. val releaseFiles = releaseVariant.outputs.map { it.outputFile }
  75. val apkFile = releaseFiles.single { it.exists() && it.extension == "apk" }
  76. val defaultConfig = android.defaultConfig
  77. val properties = mapOf(
  78. "apkSize" to "%.2f".format(apkFile.length().toFloat() / 1024 / 1024),
  79. "applicationId" to defaultConfig.applicationId,
  80. "versionName" to defaultConfig.versionName,
  81. "versionCode" to defaultConfig.versionCode?.toString(),
  82. "minSdkVersion" to defaultConfig.minSdkVersion?.apiLevel?.toString(),
  83. "targetSdkVersion" to defaultConfig.targetSdkVersion?.apiLevel?.toString(),
  84. "repository" to "sirekanyan/knigopis"
  85. )
  86. properties.forEach { (key, value) ->
  87. if (value.isNullOrBlank()) {
  88. logger.warn("Readme property '$key' is empty")
  89. }
  90. }
  91. rootProject.file("README.md").printWriter().use { readme ->
  92. rootProject.file("readme.md").forEachLine { inputLine ->
  93. readme.appendLine(
  94. properties.entries.fold(inputLine) { line, (key, value) ->
  95. line.replace("{{$key}}", value.orEmpty())
  96. }
  97. )
  98. }
  99. }
  100. }
  101. }