build.gradle.kts 12 KB

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