build.gradle 9.7 KB

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