build.gradle.kts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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(29)
  11. buildToolsVersion("29.0.3")
  12. defaultConfig {
  13. applicationId = "com.sirekanyan.knigopis"
  14. minSdkVersion(21)
  15. targetSdkVersion(29)
  16. versionCode = 29
  17. versionName = "0.3.2"
  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. }
  28. buildTypes {
  29. getByName("release") {
  30. isMinifyEnabled = true
  31. isShrinkResources = true
  32. proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard")
  33. }
  34. getByName("debug") {
  35. applicationIdSuffix = ".debug"
  36. }
  37. }
  38. compileOptions {
  39. sourceCompatibility = JavaVersion.VERSION_1_8
  40. targetCompatibility = JavaVersion.VERSION_1_8
  41. }
  42. }
  43. dependencies {
  44. // kotlin standard library
  45. implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72")
  46. // androidx libraries
  47. implementation("androidx.appcompat:appcompat:1.1.0")
  48. implementation("androidx.constraintlayout:constraintlayout:1.1.3")
  49. implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
  50. implementation("androidx.browser:browser:1.2.0")
  51. // rxjava
  52. implementation("io.reactivex.rxjava2:rxjava:2.2.19")
  53. implementation("io.reactivex.rxjava2:rxkotlin:2.4.0")
  54. implementation("io.reactivex.rxjava2:rxandroid:2.1.1")
  55. // retrofit
  56. implementation("com.squareup.retrofit2:retrofit:2.9.0")
  57. implementation("com.squareup.retrofit2:adapter-rxjava2:2.9.0")
  58. implementation("com.squareup.retrofit2:converter-gson:2.9.0")
  59. // okhttp
  60. @Suppress("GradleDependency")
  61. implementation("com.squareup.okhttp3:logging-interceptor:3.14.9")
  62. // etc
  63. implementation("com.google.android.material:material:1.1.0")
  64. implementation("com.github.bumptech.glide:glide:4.11.0")
  65. // crash reporting
  66. implementation("ch.acra:acra-http:5.1.3")
  67. }
  68. task("updateReadme") {
  69. dependsOn("assembleRelease")
  70. doLast {
  71. val releaseVariant = android.applicationVariants.first { it.name == "release" }
  72. val releaseFiles = releaseVariant.outputs.map { it.outputFile }
  73. val apkFile = releaseFiles.single { it.exists() && it.extension == "apk" }
  74. val properties = mapOf(
  75. "apkSize" to "%.2f".format(apkFile.length().toFloat() / 1024 / 1024),
  76. "appVersion" to android.defaultConfig.versionName.orEmpty(),
  77. "minSdkVersion" to android.defaultConfig.minSdkVersion?.apiLevel?.toString().orEmpty()
  78. )
  79. rootProject.file("README.md").printWriter().use { readme ->
  80. rootProject.file("readme.md").forEachLine { inputLine ->
  81. readme.appendln(
  82. properties.entries.fold(inputLine) { line, (key, value) ->
  83. line.replace("{{$key}}", value)
  84. }
  85. )
  86. }
  87. }
  88. }
  89. }