build.gradle 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. plugins {
  2. // id "com.android.application"
  3. // id 'org.jetbrains.kotlin.android'
  4. // id 'kotlin-parcelize'
  5. // //id 'kotlin-kapt'
  6. // id 'com.google.devtools.ksp'
  7. // id "com.google.gms.google-services"
  8. alias libs.plugins.compose.compiler
  9. alias libs.plugins.android.application
  10. alias libs.plugins.kotlin.android
  11. alias libs.plugins.kotlin.parcelize
  12. alias libs.plugins.room
  13. alias libs.plugins.ksp
  14. alias libs.plugins.google.services
  15. }
  16. apply from: 'download.gradle'
  17. def versionPropsFile = file("version.properties")
  18. def versionProps = new Properties()
  19. versionProps.load(new FileInputStream(versionPropsFile))
  20. ext {
  21. versionMajor = versionProps['VERSION_MAJOR'].toInteger()
  22. versionMinor = versionProps['VERSION_MINOR'].toInteger()
  23. versionPatch = versionProps['VERSION_PATCH'].toInteger()
  24. versionSuffix = versionProps['VERSION_SUFFIX'] ?: ""
  25. }
  26. def name = "legado"
  27. def gitCommits = Integer.parseInt('git rev-list HEAD --count'.execute().text.trim())
  28. ext.versionBuild = gitCommits
  29. ext.versionName = "${ext.versionMajor}.${ext.versionMinor}.${ext.versionPatch}${ext.versionSuffix}"
  30. def getGitCommitHash() {
  31. try {
  32. def stdout = new ByteArrayOutputStream()
  33. ExecOperations.exec {
  34. commandLine 'git', 'rev-parse', '--short', 'HEAD'
  35. standardOutput = stdout
  36. }
  37. return stdout.toString().trim()
  38. } catch (Exception ignored) {
  39. return "unknown"
  40. }
  41. }
  42. android {
  43. compileSdk = compile_sdk_version
  44. namespace = "io.legado.app"
  45. buildFeatures {
  46. compose = true
  47. }
  48. kotlin {
  49. jvmToolchain {
  50. languageVersion.set(JavaLanguageVersion.of(21))
  51. vendor.set(JvmVendorSpec.ADOPTIUM)
  52. }
  53. }
  54. signingConfigs {
  55. if (project.hasProperty("RELEASE_STORE_FILE")) {
  56. myConfig {
  57. storeFile file(RELEASE_STORE_FILE)
  58. storePassword RELEASE_STORE_PASSWORD
  59. keyAlias RELEASE_KEY_ALIAS
  60. keyPassword RELEASE_KEY_PASSWORD
  61. v1SigningEnabled true
  62. v2SigningEnabled true
  63. enableV3Signing = true
  64. enableV4Signing = true
  65. }
  66. }
  67. }
  68. defaultConfig {
  69. applicationId "io.legato.kazusa"
  70. minSdk 26
  71. targetSdk 36
  72. versionCode 10000 + gitCommits
  73. versionName project.ext.versionName
  74. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  75. project.ext.set("archivesBaseName", name + "_" + versionName)
  76. buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
  77. buildConfigField "String", "Cronet_Main_Version", "\"$CronetMainVersion\""
  78. javaCompileOptions {
  79. annotationProcessorOptions {
  80. arguments += [
  81. "room.incremental" : "true",
  82. "room.expandProjection": "true",
  83. "room.schemaLocation" : "$projectDir/schemas".toString()
  84. ]
  85. }
  86. }
  87. def buildTime = new Date().format("yyyy-MM-dd HH:mm:ss", TimeZone.getTimeZone("UTC"))
  88. buildConfigField "String", "BUILD_TIME", "\"${buildTime}\""
  89. }
  90. buildFeatures {
  91. buildConfig = true
  92. viewBinding = true
  93. }
  94. buildTypes {
  95. release {
  96. if (project.hasProperty("RELEASE_STORE_FILE")) {
  97. signingConfig signingConfigs.myConfig
  98. }
  99. //applicationIdSuffix '.release'
  100. manifestPlaceholders.put("app_name", "@string/app_name")
  101. minifyEnabled = true
  102. shrinkResources = true
  103. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', 'cronet-proguard-rules.pro'
  104. }
  105. debug {
  106. applicationIdSuffix ".debug"
  107. if (project.hasProperty("RELEASE_STORE_FILE")) {
  108. signingConfig signingConfigs.myConfig
  109. }
  110. manifestPlaceholders.put("app_name", "@string/app_name")
  111. //applicationIdSuffix '.debug'
  112. versionNameSuffix "_debug+${getGitCommitHash()}"
  113. minifyEnabled false
  114. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', 'cronet-proguard-rules.pro'
  115. }
  116. }
  117. splits {
  118. abi {
  119. enable = true
  120. reset()
  121. //noinspection ChromeOsAbiSupport
  122. include 'armeabi-v7a', 'arm64-v8a'
  123. universalApk = true
  124. }
  125. }
  126. //noinspection GrDeprecatedAPIUsage
  127. flavorDimensions = ['mode']
  128. productFlavors {
  129. app {
  130. dimension "mode"
  131. manifestPlaceholders.put("APP_CHANNEL_VALUE", "app")
  132. }
  133. }
  134. android.applicationVariants.configureEach { variant ->
  135. variant.outputs.configureEach { output ->
  136. def abi = output.getFilter(com.android.build.OutputFile.ABI)
  137. def flavor = variant.productFlavors[0].name
  138. def baseVersionName = variant.versionName
  139. def apkName = "${name}_${flavor}_${baseVersionName}"
  140. if (abi != null) {
  141. apkName += "_${abi}"
  142. }
  143. apkName += ".apk"
  144. output.outputFileName = apkName
  145. }
  146. }
  147. room {
  148. schemaDirectory "$projectDir/schemas"
  149. }
  150. // 设定Room的KSP参数
  151. ksp {
  152. arg("room.incremental", "true")
  153. arg("room.expandProjection", "true")
  154. arg("room.generateKotlin", "false")
  155. //arg("room.schemaLocation", "$projectDir/schemas")
  156. }
  157. compileOptions {
  158. // Flag to enable support for the new language APIs
  159. coreLibraryDesugaringEnabled = true
  160. // Sets Java compatibility
  161. sourceCompatibility JavaVersion.VERSION_21
  162. targetCompatibility JavaVersion.VERSION_21
  163. }
  164. packaging {
  165. resources.excludes.add('META-INF/*')
  166. }
  167. sourceSets {
  168. // Adds exported schema location as test app assets.
  169. androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
  170. }
  171. lint {
  172. checkDependencies = true
  173. }
  174. tasks.withType(JavaCompile).tap {
  175. configureEach {
  176. //options.compilerArgs << "-Xlint:unchecked"
  177. }
  178. }
  179. }
  180. dependencies {
  181. //compileOnly "com.android.tools.build:gradle:$agp_version"
  182. //noinspection GradleDependency,GradlePackageUpdate
  183. //coreLibraryDesugaring('com.android.tools:desugar_jdk_libs_nio:2.0.4')
  184. coreLibraryDesugaring(libs.desugar)
  185. testImplementation(libs.junit)
  186. androidTestImplementation(libs.bundles.androidTest)
  187. //kotlin
  188. //noinspection GradleDependency,DifferentStdlibGradleVersion
  189. implementation(libs.kotlin.stdlib)
  190. //Kotlin反射
  191. //noinspection GradleDependency,DifferentStdlibGradleVersion
  192. //implementation(libs.kotlin.reflect)
  193. //协程
  194. //def coroutines_version = '1.7.3'
  195. implementation(libs.bundles.coroutines)
  196. //androidX
  197. implementation(libs.core.ktx)
  198. implementation(libs.appcompat.appcompat)
  199. implementation(libs.activity.ktx)
  200. implementation(libs.fragment.ktx)
  201. implementation(libs.preference.ktx)
  202. implementation(libs.androidx.constraintlayout)
  203. implementation(libs.androidx.swiperefreshlayout)
  204. implementation(libs.androidx.recyclerview)
  205. implementation(libs.androidx.viewpager2)
  206. implementation(libs.androidx.webkit)
  207. //google
  208. implementation(libs.material)
  209. implementation(libs.flexbox)
  210. implementation(libs.gson)
  211. //lifecycle
  212. implementation(libs.lifecycle.common.java8)
  213. implementation(libs.lifecycle.service)
  214. //media
  215. implementation(libs.media.media)
  216. // For media playback using ExoPlayer
  217. implementation(libs.media3.exoplayer)
  218. // For loading data using the OkHttp network stack
  219. implementation(libs.media3.datasource.okhttp)
  220. // For exposing and controlling media sessions
  221. //implementation "androidx.media3:media3-session:$media3_version"
  222. //Splitties
  223. implementation(libs.splitties.appctx)
  224. implementation(libs.splitties.systemservices)
  225. implementation(libs.splitties.views)
  226. //room sql语句不高亮解决方法https://issuetracker.google.com/issues/234612964#comment6
  227. implementation(libs.room.runtime)
  228. implementation(libs.room.ktx)
  229. //kapt("androidx.room:room-compiler:$room_version")
  230. ksp(libs.room.compiler)
  231. androidTestImplementation(libs.room.testing)
  232. //liveEventBus
  233. implementation(libs.liveeventbus)
  234. //规则相关
  235. implementation(libs.jsoup)
  236. implementation(libs.json.path)
  237. implementation(libs.jsoupxpath)
  238. implementation(project(path: ':modules:book'))
  239. implementation(project(path: ':modules:rhino'))
  240. //JS rhino
  241. //网络
  242. implementation(libs.okhttp)
  243. implementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
  244. implementation(libs.protobuf.javalite)
  245. //Glide
  246. implementation(libs.glide.glide)
  247. implementation(libs.glide.okhttp)
  248. ksp(libs.glide.ksp)
  249. //Svg
  250. implementation(libs.androidsvg)
  251. //Glide svg plugin
  252. implementation(libs.glide.svg)
  253. //webServer
  254. implementation(libs.nanohttpd.nanohttpd)
  255. implementation(libs.nanohttpd.websocket)
  256. //二维码
  257. //noinspection GradleDependency
  258. implementation(libs.zxing.lite)
  259. //颜色选择
  260. implementation(libs.colorpicker)
  261. //压缩解压
  262. implementation libs.libarchive
  263. //apache
  264. implementation(libs.commons.text)
  265. //MarkDown
  266. implementation(libs.markwon.core)
  267. implementation(libs.markwon.image.glide)
  268. implementation(libs.markwon.ext.tables)
  269. implementation(libs.markwon.html)
  270. //转换繁体
  271. implementation(libs.quick.chinese.transfer.core)
  272. //加解密类库,有些书源使用
  273. //noinspection GradleDependency,GradlePackageUpdate
  274. implementation(libs.hutool.crypto)
  275. //firebase, 崩溃统计和性能统计
  276. implementation platform(libs.firebase.bom)
  277. implementation libs.firebase.analytics
  278. implementation libs.firebase.perf
  279. implementation libs.glide.recyclerview
  280. //LeakCanary, 内存泄露检测
  281. //debugImplementation('com.squareup.leakcanary:leakcanary-android:2.7')
  282. //com.github.AmrDeveloper:CodeView代码编辑已集成到应用内
  283. //epubLib集成到应用内
  284. implementation libs.androidx.datastore.preferences
  285. implementation libs.androidx.palette
  286. implementation libs.androidx.core.splashscreen
  287. implementation libs.androidx.startup.runtime
  288. // Compose 基础
  289. implementation platform(libs.androidx.compose.bom)
  290. implementation libs.activity.compose
  291. implementation libs.androidx.compose.ui
  292. implementation libs.androidx.compose.ui.tooling.preview
  293. debugImplementation libs.androidx.compose.ui.tooling
  294. // Material3
  295. implementation libs.androidx.compose.material3
  296. // Lifecycle
  297. implementation libs.androidx.lifecycle.runtime.compose
  298. // Activity
  299. implementation libs.androidx.activity.compose
  300. // Coil
  301. implementation libs.coil.compose
  302. // accompanist – WebView(打开网页)
  303. implementation libs.accompanist.webview
  304. // Markdown 渲染(Compose MD)
  305. // implementation libs.markdown.compose
  306. // 协程
  307. implementation libs.kotlinx.coroutines.android
  308. implementation libs.androidx.lifecycle.runtime.compose
  309. implementation libs.androidx.lifecycle.viewmodel.compose
  310. implementation libs.androidx.compose.animation
  311. implementation libs.androidx.compose.foundation
  312. implementation libs.androidx.constraintlayout.compose
  313. implementation libs.androidx.compose.ui.viewbinding
  314. implementation libs.androidx.navigation.compose
  315. implementation libs.androidx.compose.material
  316. implementation libs.compose.materialIcons
  317. implementation(platform(libs.koin.bom))
  318. implementation(libs.koin.core)
  319. implementation(libs.koin.android)
  320. implementation(libs.koin.compose)
  321. implementation(libs.koin.compose.viewmodel)
  322. }