build.gradle.kts 10 KB

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