build.gradle.kts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
  2. import org.jmailen.gradle.kotlinter.tasks.LintTask
  3. plugins {
  4. id("com.android.application")
  5. id("com.mikepenz.aboutlibraries.plugin")
  6. kotlin("android")
  7. kotlin("plugin.serialization")
  8. id("com.github.zellius.shortcut-helper")
  9. }
  10. if (gradle.startParameter.taskRequests.toString().contains("Standard")) {
  11. apply<com.google.gms.googleservices.GoogleServicesPlugin>()
  12. }
  13. shortcutHelper.setFilePath("./shortcuts.xml")
  14. val SUPPORTED_ABIS = setOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
  15. android {
  16. namespace = "eu.kanade.tachiyomi"
  17. defaultConfig {
  18. applicationId = "eu.kanade.tachiyomi"
  19. versionCode = 94
  20. versionName = "0.14.3"
  21. buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
  22. buildConfigField("String", "COMMIT_SHA", "\"${getGitSha()}\"")
  23. buildConfigField("String", "BUILD_TIME", "\"${getBuildTime()}\"")
  24. buildConfigField("boolean", "INCLUDE_UPDATER", "false")
  25. buildConfigField("boolean", "PREVIEW", "false")
  26. // Please disable ACRA or use your own instance in forked versions of the project
  27. buildConfigField("String", "ACRA_URI", "\"https://tachiyomi.kanade.eu/crash_report\"")
  28. ndk {
  29. abiFilters += SUPPORTED_ABIS
  30. }
  31. testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
  32. }
  33. splits {
  34. abi {
  35. isEnable = true
  36. reset()
  37. include(*SUPPORTED_ABIS.toTypedArray())
  38. isUniversalApk = true
  39. }
  40. }
  41. buildTypes {
  42. named("debug") {
  43. versionNameSuffix = "-${getCommitCount()}"
  44. applicationIdSuffix = ".debug"
  45. isPseudoLocalesEnabled = true
  46. }
  47. named("release") {
  48. isShrinkResources = true
  49. isMinifyEnabled = true
  50. proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro")
  51. }
  52. create("preview") {
  53. initWith(getByName("release"))
  54. buildConfigField("boolean", "PREVIEW", "true")
  55. val debugType = getByName("debug")
  56. signingConfig = debugType.signingConfig
  57. versionNameSuffix = debugType.versionNameSuffix
  58. applicationIdSuffix = debugType.applicationIdSuffix
  59. matchingFallbacks.add("release")
  60. }
  61. create("benchmark") {
  62. initWith(getByName("release"))
  63. signingConfig = signingConfigs.getByName("debug")
  64. matchingFallbacks.add("release")
  65. isDebuggable = false
  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. packagingOptions {
  87. resources.excludes.addAll(listOf(
  88. "META-INF/DEPENDENCIES",
  89. "LICENSE.txt",
  90. "META-INF/LICENSE",
  91. "META-INF/LICENSE.txt",
  92. "META-INF/README.md",
  93. "META-INF/NOTICE",
  94. "META-INF/*.kotlin_module",
  95. ))
  96. }
  97. dependenciesInfo {
  98. includeInApk = false
  99. }
  100. buildFeatures {
  101. viewBinding = true
  102. compose = true
  103. // Disable some unused things
  104. aidl = false
  105. renderScript = false
  106. shaders = false
  107. }
  108. lint {
  109. abortOnError = false
  110. checkReleaseBuilds = false
  111. }
  112. composeOptions {
  113. kotlinCompilerExtensionVersion = compose.versions.compiler.get()
  114. }
  115. }
  116. dependencies {
  117. implementation(project(":i18n"))
  118. implementation(project(":core"))
  119. implementation(project(":source-api"))
  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. implementation(compose.ui.tooling)
  134. implementation(compose.ui.util)
  135. implementation(compose.accompanist.webview)
  136. implementation(compose.accompanist.flowlayout)
  137. implementation(compose.accompanist.permissions)
  138. implementation(compose.accompanist.themeadapter)
  139. implementation(compose.accompanist.systemuicontroller)
  140. implementation(androidx.paging.runtime)
  141. implementation(androidx.paging.compose)
  142. implementation(libs.bundles.sqlite)
  143. implementation(kotlinx.reflect)
  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.coordinatorlayout)
  152. implementation(androidx.corektx)
  153. implementation(androidx.splashscreen)
  154. implementation(androidx.recyclerview)
  155. implementation(androidx.viewpager)
  156. implementation(androidx.profileinstaller)
  157. implementation(androidx.bundles.lifecycle)
  158. // Job scheduling
  159. implementation(androidx.bundles.workmanager)
  160. // RX
  161. implementation(libs.bundles.reactivex)
  162. implementation(libs.flowreactivenetwork)
  163. // Network client
  164. implementation(libs.bundles.okhttp)
  165. implementation(libs.okio)
  166. // TLS 1.3 support for Android < 10
  167. implementation(libs.conscrypt.android)
  168. // Data serialization (JSON, protobuf)
  169. implementation(kotlinx.bundles.serialization)
  170. // HTML parser
  171. implementation(libs.jsoup)
  172. // Disk
  173. implementation(libs.disklrucache)
  174. implementation(libs.unifile)
  175. implementation(libs.junrar)
  176. // Preferences
  177. implementation(libs.preferencektx)
  178. // Dependency injection
  179. implementation(libs.injekt.core)
  180. // Image loading
  181. implementation(libs.bundles.coil)
  182. implementation(libs.subsamplingscaleimageview) {
  183. exclude(module = "image-decoder")
  184. }
  185. implementation(libs.image.decoder)
  186. // Sort
  187. implementation(libs.natural.comparator)
  188. // UI libraries
  189. implementation(libs.material)
  190. implementation(libs.flexible.adapter.core)
  191. implementation(libs.flexible.adapter.ui)
  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.cascade)
  200. implementation(libs.bundles.voyager)
  201. implementation(libs.wheelpicker)
  202. implementation(libs.materialmotion.core)
  203. // Logging
  204. implementation(libs.logcat)
  205. // Crash reports/analytics
  206. implementation(libs.acra.http)
  207. "standardImplementation"(libs.firebase.analytics)
  208. // Shizuku
  209. implementation(libs.bundles.shizuku)
  210. // Tests
  211. testImplementation(libs.junit)
  212. // For detecting memory leaks; see https://square.github.io/leakcanary/
  213. // debugImplementation(libs.leakcanary.android)
  214. implementation(libs.leakcanary.plumber)
  215. }
  216. androidComponents {
  217. beforeVariants { variantBuilder ->
  218. // Disables standardBenchmark
  219. if (variantBuilder.buildType == "benchmark") {
  220. variantBuilder.enable = variantBuilder.productFlavors.containsAll(listOf("default" to "dev"))
  221. }
  222. }
  223. onVariants(selector().withFlavor("default" to "standard")) {
  224. // Only excluding in standard flavor because this breaks
  225. // Layout Inspector's Compose tree
  226. it.packaging.resources.excludes.add("META-INF/*.version")
  227. }
  228. }
  229. tasks {
  230. withType<LintTask>().configureEach {
  231. exclude { it.file.path.contains("generated[\\\\/]".toRegex()) }
  232. }
  233. // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers)
  234. withType<KotlinCompile> {
  235. kotlinOptions.freeCompilerArgs += listOf(
  236. "-opt-in=coil.annotation.ExperimentalCoilApi",
  237. "-opt-in=com.google.accompanist.permissions.ExperimentalPermissionsApi",
  238. "-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi",
  239. "-opt-in=androidx.compose.material.ExperimentalMaterialApi",
  240. "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
  241. "-opt-in=androidx.compose.material.ExperimentalMaterialApi",
  242. "-opt-in=androidx.compose.ui.ExperimentalComposeUiApi",
  243. "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
  244. "-opt-in=androidx.compose.animation.ExperimentalAnimationApi",
  245. "-opt-in=androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi",
  246. "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
  247. "-opt-in=kotlinx.coroutines.FlowPreview",
  248. "-opt-in=kotlinx.coroutines.InternalCoroutinesApi",
  249. "-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
  250. )
  251. if (project.findProperty("tachiyomi.enableComposeCompilerMetrics") == "true") {
  252. kotlinOptions.freeCompilerArgs += listOf(
  253. "-P",
  254. "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" +
  255. project.buildDir.absolutePath + "/compose_metrics"
  256. )
  257. kotlinOptions.freeCompilerArgs += listOf(
  258. "-P",
  259. "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" +
  260. project.buildDir.absolutePath + "/compose_metrics"
  261. )
  262. }
  263. }
  264. }
  265. buildscript {
  266. dependencies {
  267. classpath(kotlinx.gradle)
  268. }
  269. }