build.gradle.kts 4.0 KB

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