build.gradle 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. kotlin {
  20. jvmToolchain {
  21. languageVersion.set(JavaLanguageVersion.of("11"))
  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 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. android.applicationVariants.all { variant ->
  83. variant.outputs.all {
  84. def flavor = variant.productFlavors[0].name
  85. outputFileName = "${name}_${flavor}_${defaultConfig.versionName}.apk"
  86. }
  87. }
  88. flavorDimensions.add("mode")
  89. productFlavors {
  90. app {
  91. dimension "mode"
  92. manifestPlaceholders.put("APP_CHANNEL_VALUE", "app")
  93. }
  94. google {
  95. dimension "mode"
  96. applicationId "io.legado.play"
  97. manifestPlaceholders.put("APP_CHANNEL_VALUE", "google")
  98. }
  99. }
  100. compileOptions {
  101. // Flag to enable support for the new language APIs
  102. // 开启后rhino1.4.1会报错,rhino1.4.1已经脱糖处理
  103. coreLibraryDesugaringEnabled false
  104. // Sets Java compatibility to Java 11
  105. sourceCompatibility JavaVersion.VERSION_11
  106. targetCompatibility JavaVersion.VERSION_11
  107. }
  108. packagingOptions {
  109. resources.excludes.add('META-INF/*')
  110. }
  111. sourceSets {
  112. // Adds exported schema location as test app assets.
  113. androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
  114. }
  115. lint {
  116. checkDependencies true
  117. }
  118. tasks.withType(JavaCompile) {
  119. //options.compilerArgs << "-Xlint:unchecked"
  120. }
  121. }
  122. dependencies {
  123. compileOnly "com.android.tools.build:gradle:$agp_version"
  124. //noinspection GradleDependency,GradlePackageUpdate,脱糖库和rhino冲突,rhino1.4.1已经脱糖处理
  125. //coreLibraryDesugaring('com.android.tools:desugar_jdk_libs_nio:2.0.2')
  126. testImplementation('junit:junit:4.13.2')
  127. androidTestImplementation('androidx.test:runner:1.5.2')
  128. androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1')
  129. //kotlin
  130. //noinspection GradleDependency,DifferentStdlibGradleVersion
  131. implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
  132. //Kotlin反射
  133. //noinspection GradleDependency,DifferentStdlibGradleVersion
  134. implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
  135. //协程
  136. def coroutines_version = '1.6.4'
  137. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
  138. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
  139. //图像处理库Toolkit
  140. implementation('com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3')
  141. //androidX
  142. implementation('androidx.core:core-ktx:1.9.0')
  143. implementation('androidx.appcompat:appcompat:1.6.1')
  144. implementation('androidx.activity:activity-ktx:1.7.0')
  145. implementation('androidx.fragment:fragment-ktx:1.5.6')
  146. implementation('androidx.preference:preference-ktx:1.2.0')
  147. implementation('androidx.constraintlayout:constraintlayout:2.1.4')
  148. implementation('androidx.swiperefreshlayout:swiperefreshlayout:1.1.0')
  149. implementation('androidx.viewpager2:viewpager2:1.0.0')
  150. implementation('androidx.webkit:webkit:1.6.1')
  151. //google
  152. implementation('com.google.android.material:material:1.8.0')
  153. implementation('com.google.android.flexbox:flexbox:3.0.0')
  154. implementation('com.google.code.gson:gson:2.10.1')
  155. //lifecycle
  156. def lifecycle_version = '2.6.1'
  157. implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version")
  158. implementation("androidx.lifecycle:lifecycle-service:$lifecycle_version")
  159. //media
  160. implementation("androidx.media:media:1.6.0")
  161. implementation("com.google.android.exoplayer:exoplayer-core:$exoplayer_version")
  162. implementation("com.google.android.exoplayer:extension-okhttp:$exoplayer_version")
  163. //Splitties
  164. implementation("com.louiscad.splitties:splitties-appctx:$splitties_version")
  165. implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version")
  166. implementation("com.louiscad.splitties:splitties-views:$splitties_version")
  167. //room sql语句不高亮解决方法https://issuetracker.google.com/issues/234612964#comment6
  168. implementation("androidx.room:room-runtime:$room_version")
  169. implementation("androidx.room:room-ktx:$room_version")
  170. kapt("androidx.room:room-compiler:$room_version")
  171. androidTestImplementation("androidx.room:room-testing:$room_version")
  172. //liveEventBus
  173. implementation('io.github.jeremyliao:live-event-bus-x:1.8.0')
  174. //规则相关
  175. implementation('org.jsoup:jsoup:1.15.4')
  176. implementation('com.jayway.jsonpath:json-path:2.7.0')
  177. implementation('cn.wanghaomiao:JsoupXpath:2.5.3')
  178. implementation(project(path: ':book'))
  179. //JS rhino
  180. implementation(project(path: ':rhino'))
  181. //网络
  182. implementation('com.squareup.okhttp3:okhttp:4.10.0')
  183. appImplementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
  184. appImplementation 'com.google.protobuf:protobuf-javalite:3.22.2'
  185. //Glide
  186. def glideVersion = "4.15.1"
  187. implementation("com.github.bumptech.glide:glide:$glideVersion")
  188. kapt("com.github.bumptech.glide:compiler:$glideVersion")
  189. //Svg
  190. implementation("com.caverock:androidsvg-aar:1.4")
  191. //Glide svg plugin
  192. implementation("com.github.qoqa:glide-svg:4.0.2")
  193. //webServer
  194. def nanoHttpdVersion = "2.3.1"
  195. implementation("org.nanohttpd:nanohttpd:$nanoHttpdVersion")
  196. implementation("org.nanohttpd:nanohttpd-websocket:$nanoHttpdVersion")
  197. //二维码
  198. implementation('com.github.jenly1314:zxing-lite:2.3.1')
  199. //颜色选择
  200. implementation('com.jaredrummler:colorpicker:1.1.0')
  201. //apache
  202. implementation('org.apache.commons:commons-text:1.10.0')
  203. implementation 'org.apache.commons:commons-compress:1.23.0'
  204. implementation 'org.tukaani:xz:1.9'
  205. //RAR
  206. implementation 'com.github.junrar:junrar:7.5.4'
  207. //MarkDown
  208. def markwonVersion = "4.6.2"
  209. implementation("io.noties.markwon:core:$markwonVersion")
  210. implementation("io.noties.markwon:image-glide:$markwonVersion")
  211. implementation("io.noties.markwon:ext-tables:$markwonVersion")
  212. implementation("io.noties.markwon:html:$markwonVersion")
  213. //转换繁体
  214. implementation('com.github.liuyueyi.quick-chinese-transfer:quick-transfer-core:0.2.12')
  215. //加解密类库,有些书源使用
  216. //noinspection GradleDependency,GradlePackageUpdate
  217. implementation('cn.hutool:hutool-crypto:5.8.15')
  218. //firebase, 崩溃统计和性能统计, 会导致共存版本崩溃
  219. //implementation platform('com.google.firebase:firebase-bom:30.0.1')
  220. //implementation 'com.google.firebase:firebase-analytics-ktx:21.0.0'
  221. //implementation 'com.google.firebase:firebase-perf-ktx:20.0.6'
  222. //LeakCanary, 内存泄露检测
  223. //debugImplementation('com.squareup.leakcanary:leakcanary-android:2.7')
  224. //com.github.AmrDeveloper:CodeView代码编辑已集成到应用内
  225. //epubLib集成到应用内
  226. }