build.gradle.kts 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
  2. plugins {
  3. id("com.android.application")
  4. id("com.mikepenz.aboutlibraries.plugin")
  5. kotlin("android")
  6. kotlin("plugin.serialization")
  7. id("com.github.zellius.shortcut-helper")
  8. }
  9. shortcutHelper.setFilePath("./shortcuts.xml")
  10. val SUPPORTED_ABIS = setOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
  11. android {
  12. namespace = "eu.kanade.tachiyomi"
  13. defaultConfig {
  14. applicationId = "eu.kanade.tachiyomi"
  15. versionCode = 119
  16. versionName = "0.15.3"
  17. buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
  18. buildConfigField("String", "COMMIT_SHA", "\"${getGitSha()}\"")
  19. buildConfigField("String", "BUILD_TIME", "\"${getBuildTime()}\"")
  20. buildConfigField("boolean", "INCLUDE_UPDATER", "false")
  21. buildConfigField("boolean", "PREVIEW", "false")
  22. ndk {
  23. abiFilters += SUPPORTED_ABIS
  24. }
  25. testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
  26. }
  27. splits {
  28. abi {
  29. isEnable = true
  30. reset()
  31. include(*SUPPORTED_ABIS.toTypedArray())
  32. isUniversalApk = true
  33. }
  34. }
  35. buildTypes {
  36. named("debug") {
  37. versionNameSuffix = "-${getCommitCount()}"
  38. applicationIdSuffix = ".debug"
  39. isPseudoLocalesEnabled = true
  40. }
  41. named("release") {
  42. isShrinkResources = true
  43. isMinifyEnabled = true
  44. proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro")
  45. }
  46. create("preview") {
  47. initWith(getByName("release"))
  48. buildConfigField("boolean", "PREVIEW", "true")
  49. signingConfig = signingConfigs.getByName("debug")
  50. matchingFallbacks.add("release")
  51. val debugType = getByName("debug")
  52. versionNameSuffix = debugType.versionNameSuffix
  53. applicationIdSuffix = debugType.applicationIdSuffix
  54. }
  55. create("benchmark") {
  56. initWith(getByName("release"))
  57. signingConfig = signingConfigs.getByName("debug")
  58. matchingFallbacks.add("release")
  59. isDebuggable = false
  60. isProfileable = true
  61. versionNameSuffix = "-benchmark"
  62. applicationIdSuffix = ".benchmark"
  63. }
  64. }
  65. sourceSets {
  66. getByName("preview").res.srcDirs("src/debug/res")
  67. getByName("benchmark").res.srcDirs("src/debug/res")
  68. }
  69. flavorDimensions.add("default")
  70. productFlavors {
  71. create("standard") {
  72. buildConfigField("boolean", "INCLUDE_UPDATER", "true")
  73. dimension = "default"
  74. }
  75. create("dev") {
  76. // Include pseudolocales: https://developer.android.com/guide/topics/resources/pseudolocales
  77. resourceConfigurations.addAll(listOf("en", "en_XA", "ar_XB", "xxhdpi"))
  78. dimension = "default"
  79. }
  80. }
  81. packaging {
  82. resources.excludes.addAll(
  83. listOf(
  84. "META-INF/DEPENDENCIES",
  85. "LICENSE.txt",
  86. "META-INF/LICENSE",
  87. "META-INF/LICENSE.txt",
  88. "META-INF/README.md",
  89. "META-INF/NOTICE",
  90. "META-INF/*.kotlin_module",
  91. ),
  92. )
  93. }
  94. dependenciesInfo {
  95. includeInApk = false
  96. }
  97. buildFeatures {
  98. viewBinding = true
  99. compose = true
  100. buildConfig = true
  101. // Disable some unused things
  102. aidl = false
  103. renderScript = false
  104. shaders = false
  105. }
  106. lint {
  107. abortOnError = false
  108. checkReleaseBuilds = false
  109. }
  110. composeOptions {
  111. kotlinCompilerExtensionVersion = compose.versions.compiler.get()
  112. }
  113. }
  114. dependencies {
  115. implementation(project(":i18n"))
  116. implementation(project(":core"))
  117. implementation(project(":core-metadata"))
  118. implementation(project(":source-api"))
  119. implementation(project(":source-local"))
  120. implementation(project(":data"))
  121. implementation(project(":domain"))
  122. implementation(project(":presentation-core"))
  123. implementation(project(":presentation-widget"))
  124. // Compose
  125. implementation(platform(compose.bom))
  126. implementation(compose.activity)
  127. implementation(compose.foundation)
  128. implementation(compose.material3.core)
  129. implementation(compose.material.core)
  130. implementation(compose.material.icons)
  131. implementation(compose.animation)
  132. implementation(compose.animation.graphics)
  133. debugImplementation(compose.ui.tooling)
  134. implementation(compose.ui.tooling.preview)
  135. implementation(compose.ui.util)
  136. implementation(compose.accompanist.webview)
  137. implementation(compose.accompanist.systemuicontroller)
  138. lintChecks(compose.lintchecks)
  139. implementation(androidx.paging.runtime)
  140. implementation(androidx.paging.compose)
  141. implementation(libs.bundles.sqlite)
  142. implementation(kotlinx.reflect)
  143. implementation(kotlinx.immutables)
  144. implementation(platform(kotlinx.coroutines.bom))
  145. implementation(kotlinx.bundles.coroutines)
  146. // AndroidX libraries
  147. implementation(androidx.annotation)
  148. implementation(androidx.appcompat)
  149. implementation(androidx.biometricktx)
  150. implementation(androidx.constraintlayout)
  151. implementation(androidx.corektx)
  152. implementation(androidx.splashscreen)
  153. implementation(androidx.recyclerview)
  154. implementation(androidx.viewpager)
  155. implementation(androidx.profileinstaller)
  156. implementation(androidx.bundles.lifecycle)
  157. // Job scheduling
  158. implementation(androidx.workmanager)
  159. // RxJava
  160. implementation(libs.rxjava)
  161. // Networking
  162. implementation(libs.bundles.okhttp)
  163. implementation(libs.okio)
  164. implementation(libs.conscrypt.android) // TLS 1.3 support for Android < 10
  165. // Data serialization (JSON, protobuf, xml)
  166. implementation(kotlinx.bundles.serialization)
  167. // HTML parser
  168. implementation(libs.jsoup)
  169. // Disk
  170. implementation(libs.disklrucache)
  171. implementation(libs.unifile)
  172. implementation(libs.junrar)
  173. // Preferences
  174. implementation(libs.preferencektx)
  175. // Dependency injection
  176. implementation(libs.injekt.core)
  177. // Image loading
  178. implementation(platform(libs.coil.bom))
  179. implementation(libs.bundles.coil)
  180. implementation(libs.subsamplingscaleimageview) {
  181. exclude(module = "image-decoder")
  182. }
  183. implementation(libs.image.decoder)
  184. // UI libraries
  185. implementation(libs.material)
  186. implementation(libs.flexible.adapter.core)
  187. implementation(libs.photoview)
  188. implementation(libs.directionalviewpager) {
  189. exclude(group = "androidx.viewpager", module = "viewpager")
  190. }
  191. implementation(libs.insetter)
  192. implementation(libs.bundles.richtext)
  193. implementation(libs.aboutLibraries.compose)
  194. implementation(libs.bundles.voyager)
  195. implementation(libs.compose.materialmotion)
  196. implementation(libs.swipe)
  197. // Logging
  198. implementation(libs.logcat)
  199. // Shizuku
  200. implementation(libs.bundles.shizuku)
  201. // Tests
  202. testImplementation(libs.bundles.test)
  203. // For detecting memory leaks; see https://square.github.io/leakcanary/
  204. // debugImplementation(libs.leakcanary.android)
  205. implementation(libs.leakcanary.plumber)
  206. }
  207. androidComponents {
  208. beforeVariants { variantBuilder ->
  209. // Disables standardBenchmark
  210. if (variantBuilder.buildType == "benchmark") {
  211. variantBuilder.enable = variantBuilder.productFlavors.containsAll(
  212. listOf("default" to "dev"),
  213. )
  214. }
  215. }
  216. onVariants(selector().withFlavor("default" to "standard")) {
  217. // Only excluding in standard flavor because this breaks
  218. // Layout Inspector's Compose tree
  219. it.packaging.resources.excludes.add("META-INF/*.version")
  220. }
  221. }
  222. tasks {
  223. // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers)
  224. withType<KotlinCompile> {
  225. kotlinOptions.freeCompilerArgs += listOf(
  226. "-Xcontext-receivers",
  227. "-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi",
  228. "-opt-in=androidx.compose.material.ExperimentalMaterialApi",
  229. "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
  230. "-opt-in=androidx.compose.material.ExperimentalMaterialApi",
  231. "-opt-in=androidx.compose.ui.ExperimentalComposeUiApi",
  232. "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
  233. "-opt-in=androidx.compose.animation.ExperimentalAnimationApi",
  234. "-opt-in=androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi",
  235. "-opt-in=coil.annotation.ExperimentalCoilApi",
  236. "-opt-in=com.google.accompanist.permissions.ExperimentalPermissionsApi",
  237. "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
  238. "-opt-in=kotlinx.coroutines.FlowPreview",
  239. "-opt-in=kotlinx.coroutines.InternalCoroutinesApi",
  240. "-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
  241. )
  242. if (project.findProperty("tachiyomi.enableComposeCompilerMetrics") == "true") {
  243. kotlinOptions.freeCompilerArgs += listOf(
  244. "-P",
  245. "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" +
  246. project.layout.buildDirectory.dir("compose_metrics").get().asFile.absolutePath,
  247. )
  248. kotlinOptions.freeCompilerArgs += listOf(
  249. "-P",
  250. "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" +
  251. project.layout.buildDirectory.dir("compose_metrics").get().asFile.absolutePath,
  252. )
  253. }
  254. }
  255. }
  256. buildscript {
  257. dependencies {
  258. classpath(kotlinx.gradle)
  259. }
  260. }