build.gradle.kts 3.0 KB

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