build.gradle.kts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
  2. import java.io.ByteArrayOutputStream
  3. import java.text.SimpleDateFormat
  4. import java.util.Date
  5. import java.util.TimeZone
  6. plugins {
  7. id("com.android.application")
  8. id("com.mikepenz.aboutlibraries.plugin")
  9. kotlin("android")
  10. kotlin("kapt")
  11. kotlin("plugin.parcelize")
  12. kotlin("plugin.serialization")
  13. id("com.github.zellius.shortcut-helper")
  14. }
  15. shortcutHelper.setFilePath("./shortcuts.xml")
  16. fun runCommand(command: String): String {
  17. val byteOut = ByteArrayOutputStream()
  18. project.exec {
  19. commandLine = command.split(" ")
  20. standardOutput = byteOut
  21. }
  22. return String(byteOut.toByteArray()).trim()
  23. }
  24. // Git is needed in your system PATH for these commands to work.
  25. // If it's not installed, you can return a random value as a workaround
  26. fun getCommitCount(): String {
  27. return runCommand("git rev-list --count HEAD")
  28. // return "1"
  29. }
  30. fun getGitSha(): String {
  31. return runCommand("git rev-parse --short HEAD")
  32. // return "1"
  33. }
  34. fun getBuildTime(): String {
  35. val df = SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")
  36. df.timeZone = TimeZone.getTimeZone("UTC")
  37. return df.format(Date())
  38. }
  39. android {
  40. compileSdkVersion(AndroidConfig.compileSdk)
  41. buildToolsVersion(AndroidConfig.buildTools)
  42. ndkVersion = AndroidConfig.ndk
  43. defaultConfig {
  44. applicationId = "eu.kanade.tachiyomi"
  45. minSdkVersion(AndroidConfig.minSdk)
  46. targetSdkVersion(AndroidConfig.targetSdk)
  47. testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
  48. versionCode = 54
  49. versionName = "0.10.7"
  50. buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
  51. buildConfigField("String", "COMMIT_SHA", "\"${getGitSha()}\"")
  52. buildConfigField("String", "BUILD_TIME", "\"${getBuildTime()}\"")
  53. buildConfigField("boolean", "INCLUDE_UPDATER", "false")
  54. multiDexEnabled = true
  55. ndk {
  56. abiFilters += setOf("armeabi-v7a", "arm64-v8a", "x86")
  57. }
  58. }
  59. buildFeatures {
  60. viewBinding = true
  61. }
  62. buildTypes {
  63. named("debug") {
  64. versionNameSuffix = "-${getCommitCount()}"
  65. applicationIdSuffix = ".debug"
  66. }
  67. named("release") {
  68. /*named("postprocessing") {
  69. postprocessing {
  70. isObfuscate = false
  71. isOptimizeCode = true
  72. isRemoveUnusedCode = false
  73. isRemoveUnusedResources = true
  74. }
  75. setProguardFiles(listOf("proguard-rules.pro"))
  76. }*/
  77. }
  78. }
  79. flavorDimensions("default")
  80. productFlavors {
  81. create("standard") {
  82. buildConfigField("boolean", "INCLUDE_UPDATER", "true")
  83. dimension = "default"
  84. }
  85. create("fdroid") {
  86. dimension = "default"
  87. }
  88. create("dev") {
  89. resConfigs("en", "xxhdpi")
  90. dimension = "default"
  91. }
  92. }
  93. packagingOptions {
  94. exclude("META-INF/DEPENDENCIES")
  95. exclude("LICENSE.txt")
  96. exclude("META-INF/LICENSE")
  97. exclude("META-INF/LICENSE.txt")
  98. exclude("META-INF/NOTICE")
  99. }
  100. dependenciesInfo {
  101. includeInApk = false
  102. }
  103. lintOptions {
  104. disable("MissingTranslation", "ExtraTranslation")
  105. isAbortOnError = false
  106. isCheckReleaseBuilds = false
  107. }
  108. compileOptions {
  109. sourceCompatibility = JavaVersion.VERSION_1_8
  110. targetCompatibility = JavaVersion.VERSION_1_8
  111. }
  112. kotlinOptions {
  113. jvmTarget = JavaVersion.VERSION_1_8.toString()
  114. }
  115. }
  116. dependencies {
  117. // Source models and interfaces from Tachiyomi 1.x
  118. implementation("tachiyomi.sourceapi:source-api:1.1")
  119. // AndroidX libraries
  120. implementation("androidx.annotation:annotation:1.2.0-alpha01")
  121. implementation("androidx.appcompat:appcompat:1.3.0-alpha02")
  122. implementation("androidx.biometric:biometric-ktx:1.2.0-alpha01")
  123. implementation("androidx.browser:browser:1.3.0")
  124. implementation("androidx.cardview:cardview:1.0.0")
  125. implementation("androidx.constraintlayout:constraintlayout:2.1.0-alpha2")
  126. implementation("androidx.coordinatorlayout:coordinatorlayout:1.1.0")
  127. implementation("androidx.core:core-ktx:1.5.0-alpha05")
  128. implementation("androidx.multidex:multidex:2.0.1")
  129. implementation("androidx.preference:preference-ktx:1.1.1")
  130. implementation("androidx.recyclerview:recyclerview:1.2.0-beta01")
  131. implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01")
  132. val lifecycleVersion = "2.3.0-rc01"
  133. implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion")
  134. implementation("androidx.lifecycle:lifecycle-process:$lifecycleVersion")
  135. implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion")
  136. // Job scheduling
  137. implementation("androidx.work:work-runtime-ktx:2.5.0-beta02")
  138. // UI library
  139. implementation("com.google.android.material:material:1.3.0-beta01")
  140. "standardImplementation"("com.google.firebase:firebase-core:18.0.0")
  141. // ReactiveX
  142. implementation("io.reactivex:rxandroid:1.2.1")
  143. implementation("io.reactivex:rxjava:1.3.8")
  144. implementation("com.jakewharton.rxrelay:rxrelay:1.2.0")
  145. implementation("com.github.pwittchen:reactivenetwork:0.13.0")
  146. // Network client
  147. val okhttpVersion = "4.10.0-RC1"
  148. implementation("com.squareup.okhttp3:okhttp:$okhttpVersion")
  149. implementation("com.squareup.okhttp3:logging-interceptor:$okhttpVersion")
  150. implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:$okhttpVersion")
  151. implementation("com.squareup.okio:okio:2.9.0")
  152. // TLS 1.3 support for Android < 10
  153. implementation("org.conscrypt:conscrypt-android:2.5.1")
  154. // REST
  155. val retrofitVersion = "2.9.0"
  156. implementation("com.squareup.retrofit2:retrofit:$retrofitVersion")
  157. implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0")
  158. // JSON
  159. val kotlinSerializationVersion = "1.0.1"
  160. implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinSerializationVersion")
  161. implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$kotlinSerializationVersion")
  162. implementation("com.google.code.gson:gson:2.8.6")
  163. implementation("com.github.salomonbrys.kotson:kotson:2.5.0")
  164. // JavaScript engine
  165. implementation("com.squareup.duktape:duktape-android:1.3.0")
  166. // Disk
  167. implementation("com.jakewharton:disklrucache:2.0.2")
  168. implementation("com.github.inorichi:unifile:e9ee588")
  169. implementation("com.github.junrar:junrar:7.4.0")
  170. // HTML parser
  171. implementation("org.jsoup:jsoup:1.13.1")
  172. // Database
  173. implementation("androidx.sqlite:sqlite-ktx:2.1.0")
  174. implementation("com.github.inorichi.storio:storio-common:8be19de@aar")
  175. implementation("com.github.inorichi.storio:storio-sqlite:8be19de@aar")
  176. implementation("io.requery:sqlite-android:3.33.0")
  177. // Preferences
  178. implementation("com.github.tfcporciuncula.flow-preferences:flow-preferences:1.3.3")
  179. // Model View Presenter
  180. val nucleusVersion = "3.0.0"
  181. implementation("info.android15.nucleus:nucleus:$nucleusVersion")
  182. implementation("info.android15.nucleus:nucleus-support-v7:$nucleusVersion")
  183. // Dependency injection
  184. implementation("com.github.inorichi.injekt:injekt-core:65b0440")
  185. // Image library
  186. val glideVersion = "4.11.0"
  187. implementation("com.github.bumptech.glide:glide:$glideVersion")
  188. implementation("com.github.bumptech.glide:okhttp3-integration:$glideVersion")
  189. kapt("com.github.bumptech.glide:compiler:$glideVersion")
  190. implementation("com.github.tachiyomiorg:subsampling-scale-image-view:6caf219")
  191. // Logging
  192. implementation("com.jakewharton.timber:timber:4.7.1")
  193. // Crash reports
  194. implementation("ch.acra:acra-http:5.7.0")
  195. // Sort
  196. implementation("com.github.gpanther:java-nat-sort:natural-comparator-1.1")
  197. // UI
  198. implementation("com.dmitrymalkovich.android:material-design-dimens:1.4")
  199. implementation("com.github.dmytrodanylyk.android-process-button:library:1.0.4")
  200. implementation("eu.davidea:flexible-adapter:5.1.0")
  201. implementation("eu.davidea:flexible-adapter-ui:1.0.0")
  202. implementation("com.nightlynexus.viewstatepageradapter:viewstatepageradapter:1.1.0")
  203. implementation("com.github.chrisbanes:PhotoView:2.3.0")
  204. implementation("com.github.carlosesco:DirectionalViewPager:a844dbca0a")
  205. // 3.2.0+ introduces weird UI blinking or cut off issues on some devices
  206. val materialDialogsVersion = "3.1.1"
  207. implementation("com.afollestad.material-dialogs:core:$materialDialogsVersion")
  208. implementation("com.afollestad.material-dialogs:input:$materialDialogsVersion")
  209. implementation("com.afollestad.material-dialogs:datetime:$materialDialogsVersion")
  210. // Conductor
  211. implementation("com.bluelinelabs:conductor:2.1.5")
  212. implementation("com.bluelinelabs:conductor-support:2.1.5") {
  213. exclude(group = "com.android.support")
  214. }
  215. implementation("com.github.tachiyomiorg:conductor-support-preference:1.1.1")
  216. // FlowBinding
  217. val flowbindingVersion = "0.12.0"
  218. implementation("io.github.reactivecircus.flowbinding:flowbinding-android:$flowbindingVersion")
  219. implementation("io.github.reactivecircus.flowbinding:flowbinding-appcompat:$flowbindingVersion")
  220. implementation("io.github.reactivecircus.flowbinding:flowbinding-recyclerview:$flowbindingVersion")
  221. implementation("io.github.reactivecircus.flowbinding:flowbinding-swiperefreshlayout:$flowbindingVersion")
  222. implementation("io.github.reactivecircus.flowbinding:flowbinding-viewpager:$flowbindingVersion")
  223. // Licenses
  224. implementation("com.mikepenz:aboutlibraries:${BuildPluginsVersion.ABOUTLIB_PLUGIN}")
  225. // Tests
  226. testImplementation("junit:junit:4.13")
  227. testImplementation("org.assertj:assertj-core:3.16.1")
  228. testImplementation("org.mockito:mockito-core:1.10.19")
  229. val robolectricVersion = "3.1.4"
  230. testImplementation("org.robolectric:robolectric:$robolectricVersion")
  231. testImplementation("org.robolectric:shadows-multidex:$robolectricVersion")
  232. testImplementation("org.robolectric:shadows-play-services:$robolectricVersion")
  233. implementation(kotlin("reflect", version = BuildPluginsVersion.KOTLIN))
  234. val coroutinesVersion = "1.4.2"
  235. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
  236. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion")
  237. // For detecting memory leaks; see https://square.github.io/leakcanary/
  238. // debugImplementation("com.squareup.leakcanary:leakcanary-android:2.4")
  239. }
  240. buildscript {
  241. repositories {
  242. mavenCentral()
  243. }
  244. dependencies {
  245. classpath(kotlin("gradle-plugin", version = BuildPluginsVersion.KOTLIN))
  246. }
  247. }
  248. repositories {
  249. mavenCentral()
  250. jcenter()
  251. }
  252. tasks {
  253. // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers)
  254. withType<KotlinCompile> {
  255. kotlinOptions.freeCompilerArgs += listOf(
  256. "-Xopt-in=kotlin.Experimental",
  257. "-Xopt-in=kotlin.RequiresOptIn",
  258. "-Xuse-experimental=kotlin.ExperimentalStdlibApi",
  259. "-Xuse-experimental=kotlinx.coroutines.FlowPreview",
  260. "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
  261. "-Xuse-experimental=kotlinx.serialization.ExperimentalSerializationApi"
  262. )
  263. }
  264. // Duplicating Hebrew string assets due to some locale code issues on different devices
  265. val copyHebrewStrings = task("copyHebrewStrings", type = Copy::class) {
  266. from("./src/main/res/values-he")
  267. into("./src/main/res/values-iw")
  268. include("**/*")
  269. }
  270. preBuild {
  271. dependsOn(formatKotlin, copyHebrewStrings)
  272. }
  273. }
  274. if (gradle.startParameter.taskRequests.toString().contains("Standard")) {
  275. apply(plugin = "com.google.gms.google-services")
  276. }