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