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