build.gradle 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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 24
  41. targetSdk 33
  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. google {
  90. dimension "mode"
  91. applicationId "io.legado.play"
  92. manifestPlaceholders.put("APP_CHANNEL_VALUE", "google")
  93. }
  94. lollipop {
  95. dimension "mode"
  96. minSdk 21
  97. manifestPlaceholders.put("APP_CHANNEL_VALUE", "lollipop")
  98. }
  99. }
  100. android.applicationVariants.configureEach { variant ->
  101. variant.outputs.configureEach {
  102. def flavor = variant.productFlavors[0].name
  103. outputFileName = "${name}_${flavor}_${defaultConfig.versionName}.apk"
  104. }
  105. }
  106. // 设定Room的KSP参数
  107. ksp {
  108. arg("room.incremental", "true")
  109. arg("room.expandProjection", "true")
  110. arg("room.schemaLocation", "$projectDir/schemas")
  111. }
  112. compileOptions {
  113. // Flag to enable support for the new language APIs
  114. coreLibraryDesugaringEnabled true
  115. // Sets Java compatibility
  116. sourceCompatibility JavaVersion.VERSION_17
  117. targetCompatibility JavaVersion.VERSION_17
  118. }
  119. packaging {
  120. resources.excludes.add('META-INF/*')
  121. }
  122. sourceSets {
  123. // Adds exported schema location as test app assets.
  124. androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
  125. }
  126. lint {
  127. checkDependencies true
  128. }
  129. tasks.withType(JavaCompile).tap {
  130. configureEach {
  131. //options.compilerArgs << "-Xlint:unchecked"
  132. }
  133. }
  134. }
  135. dependencies {
  136. compileOnly "com.android.tools.build:gradle:$agp_version"
  137. //noinspection GradleDependency,GradlePackageUpdate
  138. coreLibraryDesugaring('com.android.tools:desugar_jdk_libs_nio:2.0.3')
  139. testImplementation('junit:junit:4.13.2')
  140. androidTestImplementation('androidx.test:runner:1.5.2')
  141. androidTestImplementation('androidx.test.ext:junit:1.1.5')
  142. androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1')
  143. //kotlin
  144. //noinspection GradleDependency,DifferentStdlibGradleVersion
  145. implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
  146. //Kotlin反射
  147. //noinspection GradleDependency,DifferentStdlibGradleVersion
  148. implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
  149. //协程
  150. def coroutines_version = '1.7.3'
  151. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
  152. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
  153. //图像处理库Toolkit
  154. implementation('com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3')
  155. //androidX
  156. implementation('androidx.core:core-ktx:1.10.1')
  157. implementation('androidx.appcompat:appcompat:1.6.1')
  158. implementation('androidx.activity:activity-ktx:1.7.2')
  159. implementation('androidx.fragment:fragment-ktx:1.6.1')
  160. implementation('androidx.preference:preference-ktx:1.2.0')
  161. implementation('androidx.constraintlayout:constraintlayout:2.1.4')
  162. implementation('androidx.swiperefreshlayout:swiperefreshlayout:1.1.0')
  163. implementation('androidx.viewpager2:viewpager2:1.0.0')
  164. implementation('androidx.webkit:webkit:1.7.0')
  165. //google
  166. implementation('com.google.android.material:material:1.9.0')
  167. implementation('com.google.android.flexbox:flexbox:3.0.0')
  168. implementation('com.google.code.gson:gson:2.10.1')
  169. //lifecycle
  170. def lifecycle_version = '2.6.1'
  171. implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version")
  172. implementation("androidx.lifecycle:lifecycle-service:$lifecycle_version")
  173. //media
  174. implementation("androidx.media:media:1.6.0")
  175. // For media playback using ExoPlayer
  176. implementation "androidx.media3:media3-exoplayer:$media3_version"
  177. // For loading data using the OkHttp network stack
  178. implementation "androidx.media3:media3-datasource-okhttp:$media3_version"
  179. // For exposing and controlling media sessions
  180. //implementation "androidx.media3:media3-session:$media3_version"
  181. //Splitties
  182. implementation("com.louiscad.splitties:splitties-appctx:$splitties_version")
  183. implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version")
  184. implementation("com.louiscad.splitties:splitties-views:$splitties_version")
  185. //room sql语句不高亮解决方法https://issuetracker.google.com/issues/234612964#comment6
  186. implementation("androidx.room:room-runtime:$room_version")
  187. implementation("androidx.room:room-ktx:$room_version")
  188. //kapt("androidx.room:room-compiler:$room_version")
  189. ksp("androidx.room:room-compiler:$room_version")
  190. androidTestImplementation("androidx.room:room-testing:$room_version")
  191. //liveEventBus
  192. implementation('io.github.jeremyliao:live-event-bus-x:1.8.0')
  193. //规则相关
  194. implementation('org.jsoup:jsoup:1.16.1')
  195. implementation('com.jayway.jsonpath:json-path:2.8.0')
  196. implementation('cn.wanghaomiao:JsoupXpath:2.5.3')
  197. implementation(project(path: ':modules:book'))
  198. //JS rhino
  199. appImplementation(project(path: ':modules:rhino1.7.3'))
  200. googleImplementation(project(path: ':modules:rhino1.7.3'))
  201. lollipopImplementation(project(path: ':modules:rhino1.7.3'))
  202. //网络
  203. implementation('com.squareup.okhttp3:okhttp:4.11.0')
  204. appImplementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
  205. appImplementation 'com.google.protobuf:protobuf-javalite:3.23.4'
  206. //Glide
  207. def glideVersion = "4.15.1"
  208. implementation("com.github.bumptech.glide:glide:$glideVersion")
  209. //kapt("com.github.bumptech.glide:compiler:$glideVersion")
  210. ksp("com.github.bumptech.glide:ksp:$glideVersion")
  211. //Svg
  212. implementation("com.caverock:androidsvg-aar:1.4")
  213. //Glide svg plugin
  214. implementation("com.github.qoqa:glide-svg:4.0.2")
  215. //webServer
  216. def nanoHttpdVersion = "2.3.1"
  217. implementation("org.nanohttpd:nanohttpd:$nanoHttpdVersion")
  218. implementation("org.nanohttpd:nanohttpd-websocket:$nanoHttpdVersion")
  219. //二维码
  220. implementation('com.github.jenly1314:zxing-lite:2.4.0')
  221. //颜色选择
  222. implementation('com.jaredrummler:colorpicker:1.1.0')
  223. //压缩解压
  224. implementation 'me.zhanghai.android.libarchive:library:1.0.1'
  225. //apache
  226. implementation('org.apache.commons:commons-text:1.10.0')
  227. //noinspection GradleDependency,1.23.0对安卓支持不好
  228. implementation 'org.apache.commons:commons-compress:1.22'
  229. implementation 'org.tukaani:xz:1.9'
  230. //RAR
  231. implementation 'com.github.junrar:junrar:7.5.5'
  232. //MarkDown
  233. def markwonVersion = "4.6.2"
  234. implementation("io.noties.markwon:core:$markwonVersion")
  235. implementation("io.noties.markwon:image-glide:$markwonVersion")
  236. implementation("io.noties.markwon:ext-tables:$markwonVersion")
  237. implementation("io.noties.markwon:html:$markwonVersion")
  238. //转换繁体
  239. implementation('com.github.liuyueyi.quick-chinese-transfer:quick-transfer-core:0.2.13')
  240. //加解密类库,有些书源使用
  241. //noinspection GradleDependency,GradlePackageUpdate
  242. implementation('cn.hutool:hutool-crypto:5.8.21')
  243. //firebase, 崩溃统计和性能统计, 会导致共存版本崩溃
  244. //implementation platform('com.google.firebase:firebase-bom:30.0.1')
  245. //implementation 'com.google.firebase:firebase-analytics-ktx:21.0.0'
  246. //implementation 'com.google.firebase:firebase-perf-ktx:20.0.6'
  247. //LeakCanary, 内存泄露检测
  248. //debugImplementation('com.squareup.leakcanary:leakcanary-android:2.7')
  249. //com.github.AmrDeveloper:CodeView代码编辑已集成到应用内
  250. //epubLib集成到应用内
  251. }