build.gradle.kts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. import org.gradle.api.tasks.testing.logging.TestLogEvent
  2. import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
  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. id("com.squareup.sqldelight")
  10. }
  11. if (gradle.startParameter.taskRequests.toString().contains("Standard")) {
  12. apply<com.google.gms.googleservices.GoogleServicesPlugin>()
  13. }
  14. shortcutHelper.setFilePath("./shortcuts.xml")
  15. val SUPPORTED_ABIS = setOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
  16. android {
  17. namespace = "eu.kanade.tachiyomi"
  18. compileSdk = AndroidConfig.compileSdk
  19. ndkVersion = AndroidConfig.ndk
  20. defaultConfig {
  21. applicationId = "eu.kanade.tachiyomi"
  22. minSdk = AndroidConfig.minSdk
  23. targetSdk = AndroidConfig.targetSdk
  24. versionCode = 86
  25. versionName = "0.13.6"
  26. buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
  27. buildConfigField("String", "COMMIT_SHA", "\"${getGitSha()}\"")
  28. buildConfigField("String", "BUILD_TIME", "\"${getBuildTime()}\"")
  29. buildConfigField("boolean", "INCLUDE_UPDATER", "false")
  30. buildConfigField("boolean", "PREVIEW", "false")
  31. // Please disable ACRA or use your own instance in forked versions of the project
  32. buildConfigField("String", "ACRA_URI", "\"https://tachiyomi.kanade.eu/crash_report\"")
  33. ndk {
  34. abiFilters += SUPPORTED_ABIS
  35. }
  36. testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
  37. }
  38. splits {
  39. abi {
  40. isEnable = true
  41. reset()
  42. include(*SUPPORTED_ABIS.toTypedArray())
  43. isUniversalApk = true
  44. }
  45. }
  46. buildTypes {
  47. named("debug") {
  48. versionNameSuffix = "-${getCommitCount()}"
  49. applicationIdSuffix = ".debug"
  50. }
  51. named("release") {
  52. isShrinkResources = true
  53. isMinifyEnabled = true
  54. proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro")
  55. }
  56. create("preview") {
  57. initWith(getByName("release"))
  58. buildConfigField("boolean", "PREVIEW", "true")
  59. val debugType = getByName("debug")
  60. signingConfig = debugType.signingConfig
  61. versionNameSuffix = debugType.versionNameSuffix
  62. applicationIdSuffix = debugType.applicationIdSuffix
  63. matchingFallbacks.add("release")
  64. }
  65. create("benchmark") {
  66. initWith(getByName("release"))
  67. signingConfig = signingConfigs.getByName("debug")
  68. matchingFallbacks.add("release")
  69. isDebuggable = false
  70. versionNameSuffix = "-benchmark"
  71. applicationIdSuffix = ".benchmark"
  72. }
  73. }
  74. sourceSets {
  75. getByName("preview").res.srcDirs("src/debug/res")
  76. getByName("benchmark").res.srcDirs("src/debug/res")
  77. }
  78. flavorDimensions.add("default")
  79. productFlavors {
  80. create("standard") {
  81. buildConfigField("boolean", "INCLUDE_UPDATER", "true")
  82. dimension = "default"
  83. }
  84. create("dev") {
  85. resourceConfigurations.addAll(listOf("en", "xxhdpi"))
  86. dimension = "default"
  87. }
  88. }
  89. packagingOptions {
  90. resources.excludes.addAll(listOf(
  91. "META-INF/DEPENDENCIES",
  92. "LICENSE.txt",
  93. "META-INF/LICENSE",
  94. "META-INF/LICENSE.txt",
  95. "META-INF/README.md",
  96. "META-INF/NOTICE",
  97. "META-INF/*.kotlin_module",
  98. "META-INF/*.version",
  99. ))
  100. }
  101. dependenciesInfo {
  102. includeInApk = false
  103. }
  104. buildFeatures {
  105. viewBinding = true
  106. compose = true
  107. // Disable some unused things
  108. aidl = false
  109. renderScript = false
  110. shaders = false
  111. }
  112. lint {
  113. abortOnError = false
  114. checkReleaseBuilds = false
  115. }
  116. composeOptions {
  117. kotlinCompilerExtensionVersion = compose.versions.compiler.get()
  118. }
  119. compileOptions {
  120. sourceCompatibility = JavaVersion.VERSION_11
  121. targetCompatibility = JavaVersion.VERSION_11
  122. }
  123. kotlinOptions {
  124. jvmTarget = JavaVersion.VERSION_11.toString()
  125. }
  126. sqldelight {
  127. database("Database") {
  128. packageName = "eu.kanade.tachiyomi"
  129. dialect = "sqlite:3.24"
  130. }
  131. }
  132. }
  133. dependencies {
  134. implementation(project(":i18n"))
  135. implementation(project(":core"))
  136. implementation(project(":source-api"))
  137. // Compose
  138. implementation(compose.activity)
  139. implementation(compose.foundation)
  140. implementation(compose.material3.core)
  141. implementation(compose.material3.windowsizeclass)
  142. implementation(compose.material3.adapter)
  143. implementation(compose.material.icons)
  144. implementation(compose.animation)
  145. implementation(compose.animation.graphics)
  146. implementation(compose.ui.tooling)
  147. implementation(compose.ui.util)
  148. implementation(compose.accompanist.webview)
  149. implementation(compose.accompanist.swiperefresh)
  150. implementation(compose.accompanist.flowlayout)
  151. implementation(compose.accompanist.pager.core)
  152. implementation(compose.accompanist.pager.indicators)
  153. implementation(compose.accompanist.permissions)
  154. implementation(androidx.paging.runtime)
  155. implementation(androidx.paging.compose)
  156. implementation(libs.bundles.sqlite)
  157. implementation(androidx.sqlite)
  158. implementation(libs.sqldelight.android.driver)
  159. implementation(libs.sqldelight.coroutines)
  160. implementation(libs.sqldelight.android.paging)
  161. implementation(kotlinx.reflect)
  162. implementation(kotlinx.bundles.coroutines)
  163. // AndroidX libraries
  164. implementation(androidx.annotation)
  165. implementation(androidx.appcompat)
  166. implementation(androidx.biometricktx)
  167. implementation(androidx.constraintlayout)
  168. implementation(androidx.coordinatorlayout)
  169. implementation(androidx.corektx)
  170. implementation(androidx.splashscreen)
  171. implementation(androidx.recyclerview)
  172. implementation(androidx.viewpager)
  173. implementation(androidx.glance)
  174. implementation(androidx.profileinstaller)
  175. implementation(androidx.bundles.lifecycle)
  176. // Job scheduling
  177. implementation(androidx.bundles.workmanager)
  178. // RX
  179. implementation(libs.bundles.reactivex)
  180. implementation(libs.flowreactivenetwork)
  181. // Network client
  182. implementation(libs.bundles.okhttp)
  183. implementation(libs.okio)
  184. // TLS 1.3 support for Android < 10
  185. implementation(libs.conscrypt.android)
  186. // Data serialization (JSON, protobuf)
  187. implementation(kotlinx.bundles.serialization)
  188. // HTML parser
  189. implementation(libs.jsoup)
  190. // Disk
  191. implementation(libs.disklrucache)
  192. implementation(libs.unifile)
  193. implementation(libs.junrar)
  194. // Preferences
  195. implementation(libs.preferencektx)
  196. // Model View Presenter
  197. implementation(libs.bundles.nucleus)
  198. // Dependency injection
  199. implementation(libs.injekt.core)
  200. // Image loading
  201. implementation(libs.bundles.coil)
  202. implementation(libs.subsamplingscaleimageview) {
  203. exclude(module = "image-decoder")
  204. }
  205. implementation(libs.image.decoder)
  206. // Sort
  207. implementation(libs.natural.comparator)
  208. // UI libraries
  209. implementation(libs.material)
  210. implementation(libs.flexible.adapter.core)
  211. implementation(libs.flexible.adapter.ui)
  212. implementation(libs.photoview)
  213. implementation(libs.directionalviewpager) {
  214. exclude(group = "androidx.viewpager", module = "viewpager")
  215. }
  216. implementation(libs.insetter)
  217. implementation(libs.markwon)
  218. implementation(libs.aboutLibraries.compose)
  219. implementation(libs.cascade)
  220. implementation(libs.numberpicker)
  221. implementation(libs.bundles.voyager)
  222. implementation(libs.materialmotion.core)
  223. // Conductor
  224. implementation(libs.bundles.conductor)
  225. // FlowBinding
  226. implementation(libs.bundles.flowbinding)
  227. // Logging
  228. implementation(libs.logcat)
  229. // Crash reports/analytics
  230. implementation(libs.acra.http)
  231. "standardImplementation"(libs.firebase.analytics)
  232. // Shizuku
  233. implementation(libs.bundles.shizuku)
  234. // Tests
  235. testImplementation(libs.junit)
  236. // For detecting memory leaks; see https://square.github.io/leakcanary/
  237. // debugImplementation(libs.leakcanary.android)
  238. implementation(libs.leakcanary.plumber)
  239. }
  240. androidComponents {
  241. beforeVariants { variantBuilder ->
  242. // Disables standardBenchmark
  243. if (variantBuilder.buildType == "benchmark") {
  244. variantBuilder.enable = variantBuilder.productFlavors.containsAll(listOf("default" to "dev"))
  245. }
  246. }
  247. }
  248. tasks {
  249. withType<Test> {
  250. useJUnitPlatform()
  251. testLogging {
  252. events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
  253. }
  254. }
  255. withType<org.jmailen.gradle.kotlinter.tasks.LintTask>().configureEach {
  256. exclude { it.file.path.contains("generated[\\\\/]".toRegex()) }
  257. }
  258. // See https://kotlinlang.org/docs/reference/experimental.html#experimental-status-of-experimental-api(-markers)
  259. withType<KotlinCompile> {
  260. kotlinOptions.freeCompilerArgs += listOf(
  261. "-opt-in=coil.annotation.ExperimentalCoilApi",
  262. "-opt-in=com.google.accompanist.pager.ExperimentalPagerApi",
  263. "-opt-in=com.google.accompanist.permissions.ExperimentalPermissionsApi",
  264. "-opt-in=androidx.compose.material.ExperimentalMaterialApi",
  265. "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
  266. "-opt-in=androidx.compose.ui.ExperimentalComposeUiApi",
  267. "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
  268. "-opt-in=androidx.compose.animation.ExperimentalAnimationApi",
  269. "-opt-in=androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi",
  270. "-opt-in=androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi",
  271. "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
  272. "-opt-in=kotlinx.coroutines.FlowPreview",
  273. "-opt-in=kotlinx.coroutines.InternalCoroutinesApi",
  274. "-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
  275. )
  276. }
  277. preBuild {
  278. val ktlintTask = if (System.getenv("GITHUB_BASE_REF") == null) formatKotlin else lintKotlin
  279. dependsOn(ktlintTask)
  280. }
  281. }
  282. buildscript {
  283. dependencies {
  284. classpath(kotlinx.gradle)
  285. }
  286. }