build.gradle.kts 3.7 KB

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