build.gradle.kts 12 KB

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