build.gradle 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. }
  9. apply from: 'download.gradle'
  10. static def releaseTime() {
  11. return new Date().format("yy.MMddHH", TimeZone.getTimeZone("GMT+8"))
  12. }
  13. def name = "legado"
  14. def version = "3." + releaseTime()
  15. def gitCommits = Integer.parseInt('git rev-list HEAD --count'.execute().text.trim())
  16. android {
  17. compileSdk = compile_sdk_version
  18. namespace 'io.legado.app'
  19. kotlin {
  20. jvmToolchain {
  21. languageVersion.set(JavaLanguageVersion.of(17))
  22. }
  23. }
  24. signingConfigs {
  25. if (project.hasProperty("RELEASE_STORE_FILE")) {
  26. myConfig {
  27. storeFile file(RELEASE_STORE_FILE)
  28. storePassword RELEASE_STORE_PASSWORD
  29. keyAlias RELEASE_KEY_ALIAS
  30. keyPassword RELEASE_KEY_PASSWORD
  31. v1SigningEnabled true
  32. v2SigningEnabled true
  33. enableV3Signing = true
  34. enableV4Signing = true
  35. }
  36. }
  37. }
  38. defaultConfig {
  39. applicationId "io.legado.app"
  40. minSdk 21
  41. targetSdk 34
  42. versionCode 10000 + gitCommits
  43. versionName version
  44. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  45. project.ext.set("archivesBaseName", name + "_" + version)
  46. buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
  47. buildConfigField "String", "Cronet_Main_Version", "\"$CronetMainVersion\""
  48. javaCompileOptions {
  49. annotationProcessorOptions {
  50. arguments += [
  51. "room.incremental" : "true",
  52. "room.expandProjection": "true",
  53. "room.schemaLocation" : "$projectDir/schemas".toString()
  54. ]
  55. }
  56. }
  57. }
  58. buildFeatures {
  59. buildConfig true
  60. viewBinding true
  61. }
  62. buildTypes {
  63. release {
  64. if (project.hasProperty("RELEASE_STORE_FILE")) {
  65. signingConfig signingConfigs.myConfig
  66. }
  67. applicationIdSuffix '.release'
  68. minifyEnabled true
  69. shrinkResources true
  70. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  71. }
  72. debug {
  73. if (project.hasProperty("RELEASE_STORE_FILE")) {
  74. signingConfig signingConfigs.myConfig
  75. }
  76. applicationIdSuffix '.debug'
  77. versionNameSuffix 'debug'
  78. minifyEnabled false
  79. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  80. }
  81. }
  82. //noinspection GrDeprecatedAPIUsage
  83. flavorDimensions = ['mode']
  84. productFlavors {
  85. app {
  86. dimension "mode"
  87. manifestPlaceholders.put("APP_CHANNEL_VALUE", "app")
  88. }
  89. }
  90. android.applicationVariants.configureEach { variant ->
  91. variant.outputs.configureEach {
  92. def flavor = variant.productFlavors[0].name
  93. outputFileName = "${name}_${flavor}_${defaultConfig.versionName}.apk"
  94. }
  95. }
  96. // 设定Room的KSP参数
  97. ksp {
  98. arg("room.incremental", "true")
  99. arg("room.expandProjection", "true")
  100. arg("room.schemaLocation", "$projectDir/schemas")
  101. }
  102. compileOptions {
  103. // Flag to enable support for the new language APIs
  104. coreLibraryDesugaringEnabled true
  105. // Sets Java compatibility
  106. sourceCompatibility JavaVersion.VERSION_17
  107. targetCompatibility JavaVersion.VERSION_17
  108. }
  109. packaging {
  110. resources.excludes.add('META-INF/*')
  111. }
  112. sourceSets {
  113. // Adds exported schema location as test app assets.
  114. androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
  115. }
  116. lint {
  117. checkDependencies true
  118. }
  119. tasks.withType(JavaCompile).tap {
  120. configureEach {
  121. //options.compilerArgs << "-Xlint:unchecked"
  122. }
  123. }
  124. }
  125. dependencies {
  126. compileOnly "com.android.tools.build:gradle:$agp_version"
  127. //noinspection GradleDependency,GradlePackageUpdate
  128. coreLibraryDesugaring('com.android.tools:desugar_jdk_libs_nio:2.0.4')
  129. testImplementation('junit:junit:4.13.2')
  130. androidTestImplementation('androidx.test:runner:1.5.2')
  131. androidTestImplementation('androidx.test.ext:junit:1.1.5')
  132. androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1')
  133. //kotlin
  134. //noinspection GradleDependency,DifferentStdlibGradleVersion
  135. implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
  136. //Kotlin反射
  137. //noinspection GradleDependency,DifferentStdlibGradleVersion
  138. implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
  139. //协程
  140. def coroutines_version = '1.7.3'
  141. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
  142. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
  143. //图像处理库Toolkit
  144. implementation('com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3')
  145. //androidX
  146. implementation('androidx.core:core-ktx:1.12.0')
  147. implementation('androidx.appcompat:appcompat:1.6.1')
  148. implementation('androidx.activity:activity-ktx:1.8.1')
  149. implementation('androidx.fragment:fragment-ktx:1.6.2')
  150. implementation('androidx.preference:preference-ktx:1.2.1')
  151. implementation('androidx.constraintlayout:constraintlayout:2.1.4')
  152. implementation('androidx.swiperefreshlayout:swiperefreshlayout:1.1.0')
  153. implementation('androidx.viewpager2:viewpager2:1.0.0')
  154. implementation('androidx.webkit:webkit:1.9.0')
  155. //google
  156. implementation('com.google.android.material:material:1.10.0')
  157. implementation('com.google.android.flexbox:flexbox:3.0.0')
  158. implementation('com.google.code.gson:gson:2.10.1')
  159. //lifecycle
  160. def lifecycle_version = '2.6.2'
  161. implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version")
  162. implementation("androidx.lifecycle:lifecycle-service:$lifecycle_version")
  163. //media
  164. implementation("androidx.media:media:1.7.0")
  165. // For media playback using ExoPlayer
  166. implementation "androidx.media3:media3-exoplayer:$media3_version"
  167. // For loading data using the OkHttp network stack
  168. implementation "androidx.media3:media3-datasource-okhttp:$media3_version"
  169. // For exposing and controlling media sessions
  170. //implementation "androidx.media3:media3-session:$media3_version"
  171. //Splitties
  172. implementation("com.louiscad.splitties:splitties-appctx:$splitties_version")
  173. implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version")
  174. implementation("com.louiscad.splitties:splitties-views:$splitties_version")
  175. //room sql语句不高亮解决方法https://issuetracker.google.com/issues/234612964#comment6
  176. implementation("androidx.room:room-runtime:$room_version")
  177. implementation("androidx.room:room-ktx:$room_version")
  178. //kapt("androidx.room:room-compiler:$room_version")
  179. ksp("androidx.room:room-compiler:$room_version")
  180. androidTestImplementation("androidx.room:room-testing:$room_version")
  181. //liveEventBus
  182. implementation('com.github.michaellee123:LiveEventBus:1.8.14')
  183. //规则相关
  184. implementation('org.jsoup:jsoup:1.16.2')
  185. implementation('com.jayway.jsonpath:json-path:2.8.0')
  186. implementation('cn.wanghaomiao:JsoupXpath:2.5.3')
  187. implementation(project(path: ':modules:book'))
  188. //JS rhino
  189. implementation(project(path: ':modules:rhino1.7.3'))
  190. //网络
  191. implementation('com.squareup.okhttp3:okhttp:4.12.0')
  192. implementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
  193. implementation 'com.google.protobuf:protobuf-javalite:3.25.3'
  194. //Glide
  195. def glideVersion = "4.16.0"
  196. implementation("com.github.bumptech.glide:glide:$glideVersion")
  197. //kapt("com.github.bumptech.glide:compiler:$glideVersion")
  198. ksp("com.github.bumptech.glide:ksp:$glideVersion")
  199. //Svg
  200. implementation("com.caverock:androidsvg-aar:1.4")
  201. //Glide svg plugin
  202. implementation("com.github.qoqa:glide-svg:4.0.2")
  203. //webServer
  204. def nanoHttpdVersion = "2.3.1"
  205. implementation("org.nanohttpd:nanohttpd:$nanoHttpdVersion")
  206. implementation("org.nanohttpd:nanohttpd-websocket:$nanoHttpdVersion")
  207. //二维码
  208. //noinspection GradleDependency
  209. implementation('com.github.jenly1314:zxing-lite:3.0.1')
  210. //颜色选择
  211. implementation('com.jaredrummler:colorpicker:1.1.0')
  212. //压缩解压
  213. implementation 'me.zhanghai.android.libarchive:library:1.0.3'
  214. //apache
  215. implementation('org.apache.commons:commons-text:1.11.0')
  216. //MarkDown
  217. def markwonVersion = "4.6.2"
  218. implementation("io.noties.markwon:core:$markwonVersion")
  219. implementation("io.noties.markwon:image-glide:$markwonVersion")
  220. implementation("io.noties.markwon:ext-tables:$markwonVersion")
  221. implementation("io.noties.markwon:html:$markwonVersion")
  222. //转换繁体
  223. implementation('com.github.liuyueyi.quick-chinese-transfer:quick-transfer-core:0.2.13')
  224. //加解密类库,有些书源使用
  225. //noinspection GradleDependency,GradlePackageUpdate
  226. implementation('cn.hutool:hutool-crypto:5.8.22')
  227. //firebase, 崩溃统计和性能统计
  228. implementation platform('com.google.firebase:firebase-bom:32.5.0')
  229. implementation 'com.google.firebase:firebase-analytics:21.5.0'
  230. implementation 'com.google.firebase:firebase-perf:20.5.1'
  231. //LeakCanary, 内存泄露检测
  232. //debugImplementation('com.squareup.leakcanary:leakcanary-android:2.7')
  233. //com.github.AmrDeveloper:CodeView代码编辑已集成到应用内
  234. //epubLib集成到应用内
  235. }