build.gradle.kts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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 = 104
  20. versionName = "0.14.6"
  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. isProfileable = false
  60. matchingFallbacks.add("release")
  61. }
  62. create("benchmark") {
  63. initWith(getByName("release"))
  64. signingConfig = signingConfigs.getByName("debug")
  65. matchingFallbacks.add("release")
  66. isDebuggable = false
  67. versionNameSuffix = "-benchmark"
  68. applicationIdSuffix = ".benchmark"
  69. }
  70. }
  71. sourceSets {
  72. getByName("preview").res.srcDirs("src/debug/res")
  73. getByName("benchmark").res.srcDirs("src/debug/res")
  74. }
  75. flavorDimensions.add("default")
  76. productFlavors {
  77. create("standard") {
  78. buildConfigField("boolean", "INCLUDE_UPDATER", "true")
  79. dimension = "default"
  80. }
  81. create("dev") {
  82. // Include pseudolocales: https://developer.android.com/guide/topics/resources/pseudolocales
  83. resourceConfigurations.addAll(listOf("en", "en_XA", "ar_XB", "xxhdpi"))
  84. dimension = "default"
  85. }
  86. }
  87. packaging {
  88. resources.excludes.addAll(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. dependenciesInfo {
  99. includeInApk = false
  100. }
  101. buildFeatures {
  102. viewBinding = true
  103. compose = true
  104. // Disable some unused things
  105. aidl = false
  106. renderScript = false
  107. shaders = false
  108. }
  109. lint {
  110. abortOnError = false
  111. checkReleaseBuilds = false
  112. }
  113. composeOptions {
  114. kotlinCompilerExtensionVersion = compose.versions.compiler.get()
  115. }
  116. }
  117. dependencies {
  118. implementation(project(":i18n"))
  119. implementation(project(":core"))
  120. implementation(project(":core-metadata"))
  121. implementation(project(":source-api"))
  122. implementation(project(":source-local"))
  123. implementation(project(":data"))
  124. implementation(project(":domain"))
  125. implementation(project(":presentation-core"))
  126. implementation(project(":presentation-widget"))
  127. // Compose
  128. implementation(platform(compose.bom))
  129. implementation(compose.activity)
  130. implementation(compose.foundation)
  131. implementation(compose.material3.core)
  132. implementation(compose.material.core)
  133. implementation(compose.material.icons)
  134. implementation(compose.animation)
  135. implementation(compose.animation.graphics)
  136. debugImplementation(compose.ui.tooling)
  137. implementation(compose.ui.tooling.preview)
  138. implementation(compose.ui.util)
  139. implementation(compose.accompanist.webview)
  140. implementation(compose.accompanist.permissions)
  141. implementation(compose.accompanist.themeadapter)
  142. implementation(compose.accompanist.systemuicontroller)
  143. implementation(androidx.paging.runtime)
  144. implementation(androidx.paging.compose)
  145. implementation(libs.bundles.sqlite)
  146. implementation(kotlinx.reflect)
  147. implementation(platform(kotlinx.coroutines.bom))
  148. implementation(kotlinx.bundles.coroutines)
  149. // AndroidX libraries
  150. implementation(androidx.annotation)
  151. implementation(androidx.appcompat)
  152. implementation(androidx.biometricktx)
  153. implementation(androidx.constraintlayout)
  154. implementation(androidx.corektx)
  155. implementation(androidx.splashscreen)
  156. implementation(androidx.recyclerview)
  157. implementation(androidx.viewpager)
  158. implementation(androidx.profileinstaller)
  159. implementation(androidx.bundles.lifecycle)
  160. // Job scheduling
  161. implementation(androidx.bundles.workmanager)
  162. // RxJava
  163. implementation(libs.bundles.reactivex)
  164. implementation(libs.flowreactivenetwork)
  165. // Networking
  166. implementation(libs.bundles.okhttp)
  167. implementation(libs.okio)
  168. implementation(libs.conscrypt.android) // TLS 1.3 support for Android < 10
  169. // Data serialization (JSON, protobuf, xml)
  170. implementation(kotlinx.bundles.serialization)
  171. // HTML parser
  172. implementation(libs.jsoup)
  173. // Disk
  174. implementation(libs.disklrucache)
  175. implementation(libs.unifile)
  176. implementation(libs.junrar)
  177. // Preferences
  178. implementation(libs.preferencektx)
  179. // Dependency injection
  180. implementation(libs.injekt.core)
  181. // Image loading
  182. implementation(platform(libs.coil.bom))
  183. implementation(libs.bundles.coil)
  184. implementation(libs.subsamplingscaleimageview) {
  185. exclude(module = "image-decoder")
  186. }
  187. implementation(libs.image.decoder)
  188. // UI libraries
  189. implementation(libs.material)
  190. implementation(libs.flexible.adapter.core)
  191. implementation(libs.photoview)
  192. implementation(libs.directionalviewpager) {
  193. exclude(group = "androidx.viewpager", module = "viewpager")
  194. }
  195. implementation(libs.insetter)
  196. implementation(libs.bundles.richtext)
  197. implementation(libs.aboutLibraries.compose)
  198. implementation(libs.bundles.voyager)
  199. implementation(libs.compose.materialmotion)
  200. implementation(libs.compose.simpleicons)
  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(listOf("default" to "dev"))
  220. }
  221. }
  222. onVariants(selector().withFlavor("default" to "standard")) {
  223. // Only excluding in standard flavor because this breaks
  224. // Layout Inspector's Compose tree
  225. it.packaging.resources.excludes.add("META-INF/*.version")
  226. }
  227. }
  228. tasks {
  229. withType<LintTask>().configureEach {
  230. exclude { it.file.path.contains("generated[\\\\/]".toRegex()) }
  231. }
  232. // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers)
  233. withType<KotlinCompile> {
  234. kotlinOptions.freeCompilerArgs += listOf(
  235. "-Xcontext-receivers",
  236. "-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi",
  237. "-opt-in=androidx.compose.material.ExperimentalMaterialApi",
  238. "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
  239. "-opt-in=androidx.compose.material.ExperimentalMaterialApi",
  240. "-opt-in=androidx.compose.ui.ExperimentalComposeUiApi",
  241. "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
  242. "-opt-in=androidx.compose.animation.ExperimentalAnimationApi",
  243. "-opt-in=androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi",
  244. "-opt-in=coil.annotation.ExperimentalCoilApi",
  245. "-opt-in=com.google.accompanist.permissions.ExperimentalPermissionsApi",
  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. }