build.gradle 8.8 KB

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