build.gradle 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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.gms.google-services"
  7. }
  8. apply from: 'download.gradle'
  9. static def releaseTime() {
  10. return new Date().format("yy.MMddHH", TimeZone.getTimeZone("GMT+8"))
  11. }
  12. def name = "legado"
  13. def version = "3." + releaseTime()
  14. def gitCommits = Integer.parseInt('git rev-list HEAD --count'.execute().text.trim())
  15. android {
  16. compileSdk = compile_sdk_version
  17. buildToolsVersion = build_tool_version
  18. namespace 'io.legado.app'
  19. kotlinOptions {
  20. jvmTarget = "11"
  21. }
  22. signingConfigs {
  23. if (project.hasProperty("RELEASE_STORE_FILE")) {
  24. myConfig {
  25. storeFile file(RELEASE_STORE_FILE)
  26. storePassword RELEASE_STORE_PASSWORD
  27. keyAlias RELEASE_KEY_ALIAS
  28. keyPassword RELEASE_KEY_PASSWORD
  29. v1SigningEnabled true
  30. v2SigningEnabled true
  31. enableV3Signing = true
  32. enableV4Signing = true
  33. }
  34. }
  35. }
  36. defaultConfig {
  37. applicationId "io.legado.app"
  38. minSdk 21
  39. targetSdk 33
  40. versionCode 10000 + gitCommits
  41. versionName version
  42. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  43. project.ext.set("archivesBaseName", name + "_" + version)
  44. multiDexEnabled true
  45. buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
  46. buildConfigField "String", "Cronet_Main_Version", "\"$CronetMainVersion\""
  47. javaCompileOptions {
  48. annotationProcessorOptions {
  49. arguments += [
  50. "room.incremental" : "true",
  51. "room.expandProjection": "true",
  52. "room.schemaLocation" : "$projectDir/schemas".toString()
  53. ]
  54. }
  55. }
  56. }
  57. buildFeatures {
  58. buildConfig true
  59. viewBinding true
  60. }
  61. buildTypes {
  62. release {
  63. if (project.hasProperty("RELEASE_STORE_FILE")) {
  64. signingConfig signingConfigs.myConfig
  65. }
  66. applicationIdSuffix '.release'
  67. minifyEnabled true
  68. shrinkResources true
  69. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  70. }
  71. debug {
  72. if (project.hasProperty("RELEASE_STORE_FILE")) {
  73. signingConfig signingConfigs.myConfig
  74. }
  75. applicationIdSuffix '.debug'
  76. versionNameSuffix 'debug'
  77. minifyEnabled false
  78. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  79. }
  80. }
  81. android.applicationVariants.all { variant ->
  82. variant.outputs.all {
  83. def flavor = variant.productFlavors[0].name
  84. outputFileName = "${name}_${flavor}_${defaultConfig.versionName}.apk"
  85. }
  86. }
  87. flavorDimensions.add("mode")
  88. productFlavors {
  89. app {
  90. dimension "mode"
  91. manifestPlaceholders.put("APP_CHANNEL_VALUE", "app")
  92. }
  93. google {
  94. dimension "mode"
  95. applicationId "io.legado.play"
  96. manifestPlaceholders.put("APP_CHANNEL_VALUE", "google")
  97. }
  98. }
  99. compileOptions {
  100. // Flag to enable support for the new language APIs
  101. coreLibraryDesugaringEnabled true
  102. // Sets Java compatibility to Java 11
  103. sourceCompatibility JavaVersion.VERSION_11
  104. targetCompatibility JavaVersion.VERSION_11
  105. }
  106. sourceSets {
  107. // Adds exported schema location as test app assets.
  108. androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
  109. }
  110. lint {
  111. checkDependencies true
  112. }
  113. tasks.withType(JavaCompile) {
  114. //options.compilerArgs << "-Xlint:unchecked"
  115. }
  116. }
  117. dependencies {
  118. compileOnly "com.android.tools.build:gradle:$agp_version"
  119. //noinspection GradleDependency,GradlePackageUpdate
  120. coreLibraryDesugaring('com.android.tools:desugar_jdk_libs:1.2.2')
  121. testImplementation('junit:junit:4.13.2')
  122. androidTestImplementation('androidx.test:runner:1.5.2')
  123. androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1')
  124. implementation('androidx.multidex:multidex:2.0.1')
  125. //kotlin
  126. //noinspection GradleDependency,DifferentStdlibGradleVersion
  127. implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
  128. //Kotlin反射
  129. //noinspection GradleDependency,DifferentStdlibGradleVersion
  130. implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
  131. //协程
  132. def coroutines_version = '1.6.4'
  133. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
  134. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
  135. //图像处理库Toolkit
  136. implementation('com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3')
  137. //androidX
  138. implementation('androidx.core:core-ktx:1.9.0')
  139. implementation('androidx.appcompat:appcompat:1.6.0')
  140. implementation('androidx.activity:activity-ktx:1.6.1')
  141. implementation('androidx.fragment:fragment-ktx:1.5.5')
  142. implementation('androidx.preference:preference-ktx:1.2.0')
  143. implementation('androidx.constraintlayout:constraintlayout:2.1.4')
  144. implementation('androidx.swiperefreshlayout:swiperefreshlayout:1.1.0')
  145. implementation('androidx.viewpager2:viewpager2:1.0.0')
  146. implementation('androidx.webkit:webkit:1.5.0')
  147. //google
  148. implementation('com.google.android.material:material:1.7.0')
  149. implementation('com.google.android.flexbox:flexbox:3.0.0')
  150. implementation('com.google.code.gson:gson:2.10.1')
  151. //lifecycle
  152. def lifecycle_version = '2.5.1'
  153. implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version")
  154. implementation("androidx.lifecycle:lifecycle-service:$lifecycle_version")
  155. //media
  156. implementation("androidx.media:media:1.6.0")
  157. implementation("com.google.android.exoplayer:exoplayer-core:$exoplayer_version")
  158. implementation("com.google.android.exoplayer:extension-okhttp:$exoplayer_version")
  159. //Splitties
  160. implementation("com.louiscad.splitties:splitties-appctx:$splitties_version")
  161. implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version")
  162. implementation("com.louiscad.splitties:splitties-views:$splitties_version")
  163. //room
  164. implementation("androidx.room:room-runtime:$room_version")
  165. implementation("androidx.room:room-ktx:$room_version")
  166. kapt("androidx.room:room-compiler:$room_version")
  167. androidTestImplementation("androidx.room:room-testing:$room_version")
  168. //liveEventBus
  169. implementation('io.github.jeremyliao:live-event-bus-x:1.8.0')
  170. //规则相关
  171. implementation('org.jsoup:jsoup:1.15.3')
  172. implementation('com.jayway.jsonpath:json-path:2.7.0')
  173. implementation('cn.wanghaomiao:JsoupXpath:2.5.1')
  174. implementation(project(path: ':epublib'))
  175. //JS rhino
  176. //implementation('com.github.gedoor:rhino-android:1.8')
  177. implementation(fileTree(dir: 'lib', include: ['rhino-*.jar']))
  178. //网络
  179. implementation('com.squareup.okhttp3:okhttp:4.10.0')
  180. appImplementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
  181. //Glide
  182. def glideVersion = "4.14.2"
  183. implementation("com.github.bumptech.glide:glide:$glideVersion")
  184. kapt("com.github.bumptech.glide:compiler:$glideVersion")
  185. //Svg
  186. implementation("com.caverock:androidsvg-aar:1.4")
  187. //Glide svg plugin
  188. implementation("com.github.qoqa:glide-svg:4.0.2")
  189. //webServer
  190. def nanoHttpdVersion = "2.3.1"
  191. implementation("org.nanohttpd:nanohttpd:$nanoHttpdVersion")
  192. implementation("org.nanohttpd:nanohttpd-websocket:$nanoHttpdVersion")
  193. //二维码
  194. implementation('com.github.jenly1314:zxing-lite:2.3.0')
  195. //颜色选择
  196. implementation('com.jaredrummler:colorpicker:1.1.0')
  197. //apache
  198. implementation('org.apache.commons:commons-text:1.10.0')
  199. //MarkDown
  200. def markwonVersion = "4.6.2"
  201. implementation("io.noties.markwon:core:$markwonVersion")
  202. implementation("io.noties.markwon:image-glide:$markwonVersion")
  203. implementation("io.noties.markwon:ext-tables:$markwonVersion")
  204. implementation("io.noties.markwon:html:$markwonVersion")
  205. //转换繁体
  206. implementation('com.github.liuyueyi.quick-chinese-transfer:quick-transfer-core:0.2.10')
  207. //加解密类库,有些书源使用
  208. //noinspection GradleDependency,GradlePackageUpdate
  209. implementation('cn.hutool:hutool-crypto:5.8.11')
  210. //firebase, 崩溃统计和性能统计, 会导致共存版本崩溃
  211. //implementation platform('com.google.firebase:firebase-bom:30.0.1')
  212. //implementation 'com.google.firebase:firebase-analytics-ktx:21.0.0'
  213. //implementation 'com.google.firebase:firebase-perf-ktx:20.0.6'
  214. //LeakCanary, 内存泄露检测
  215. //debugImplementation('com.squareup.leakcanary:leakcanary-android:2.7')
  216. //com.github.AmrDeveloper:CodeView代码编辑已集成到应用内
  217. //epubLib集成到应用内
  218. }