build.gradle 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. compose true
  59. }
  60. buildTypes {
  61. release {
  62. if (project.hasProperty("RELEASE_STORE_FILE")) {
  63. signingConfig signingConfigs.myConfig
  64. }
  65. applicationIdSuffix '.release'
  66. minifyEnabled true
  67. shrinkResources true
  68. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  69. }
  70. debug {
  71. if (project.hasProperty("RELEASE_STORE_FILE")) {
  72. signingConfig signingConfigs.myConfig
  73. }
  74. applicationIdSuffix '.debug'
  75. versionNameSuffix 'debug'
  76. minifyEnabled false
  77. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  78. }
  79. }
  80. android.applicationVariants.all { variant ->
  81. variant.outputs.all {
  82. def flavor = variant.productFlavors[0].name
  83. outputFileName = "${name}_${flavor}_${defaultConfig.versionName}.apk"
  84. }
  85. }
  86. flavorDimensions.add("mode")
  87. productFlavors {
  88. app {
  89. dimension "mode"
  90. manifestPlaceholders.put("APP_CHANNEL_VALUE", "app")
  91. }
  92. google {
  93. dimension "mode"
  94. applicationId "io.legado.play"
  95. manifestPlaceholders.put("APP_CHANNEL_VALUE", "google")
  96. }
  97. }
  98. compileOptions {
  99. // Flag to enable support for the new language APIs
  100. coreLibraryDesugaringEnabled true
  101. // Sets Java compatibility to Java 11
  102. sourceCompatibility JavaVersion.VERSION_11
  103. targetCompatibility JavaVersion.VERSION_11
  104. }
  105. composeOptions {
  106. kotlinCompilerExtensionVersion "$compose_compiler_version"
  107. }
  108. sourceSets {
  109. // Adds exported schema location as test app assets.
  110. androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
  111. }
  112. lint {
  113. checkDependencies true
  114. }
  115. tasks.withType(JavaCompile) {
  116. //options.compilerArgs << "-Xlint:unchecked"
  117. }
  118. }
  119. dependencies {
  120. compileOnly "com.android.tools.build:gradle:$agp_version"
  121. //noinspection GradleDependency,GradlePackageUpdate
  122. coreLibraryDesugaring('com.android.tools:desugar_jdk_libs:1.2.2')
  123. testImplementation('junit:junit:4.13.2')
  124. androidTestImplementation('androidx.test:runner:1.4.0')
  125. androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0')
  126. implementation('androidx.multidex:multidex:2.0.1')
  127. //kotlin
  128. //noinspection GradleDependency,DifferentStdlibGradleVersion
  129. implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
  130. //Kotlin反射
  131. //noinspection GradleDependency,DifferentStdlibGradleVersion
  132. implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
  133. //协程
  134. def coroutines_version = '1.6.4'
  135. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
  136. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
  137. //图像处理库Toolkit
  138. implementation('com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3')
  139. //androidX
  140. implementation('androidx.core:core-ktx:1.9.0')
  141. implementation('androidx.appcompat:appcompat:1.5.1')
  142. implementation('androidx.activity:activity-ktx:1.6.0')
  143. implementation('androidx.fragment:fragment-ktx:1.5.3')
  144. implementation('androidx.preference:preference-ktx:1.2.0')
  145. implementation('androidx.constraintlayout:constraintlayout:2.1.4')
  146. implementation('androidx.swiperefreshlayout:swiperefreshlayout:1.1.0')
  147. implementation('androidx.viewpager2:viewpager2:1.0.0')
  148. implementation('androidx.webkit:webkit:1.5.0')
  149. //google
  150. implementation('com.google.android.material:material:1.6.1')
  151. implementation('com.google.android.flexbox:flexbox:3.0.0')
  152. implementation('com.google.code.gson:gson:2.9.1')
  153. //lifecycle
  154. def lifecycle_version = '2.5.1'
  155. implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version")
  156. //compose
  157. // Integration with activities
  158. implementation 'androidx.activity:activity-compose:1.6.0'
  159. // Compose Material Design
  160. implementation "androidx.compose.material:material:$compose_version"
  161. // Animations
  162. implementation "androidx.compose.animation:animation:$compose_version"
  163. // Tooling support (Previews, etc.)
  164. implementation "androidx.compose.ui:ui-tooling:$compose_version"
  165. // UI Tests
  166. androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
  167. //media
  168. implementation("androidx.media:media:1.6.0")
  169. implementation("com.google.android.exoplayer:exoplayer-core:$exoplayer_version")
  170. implementation("com.google.android.exoplayer:extension-okhttp:$exoplayer_version")
  171. //Splitties
  172. implementation("com.louiscad.splitties:splitties-appctx:$splitties_version")
  173. implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version")
  174. implementation("com.louiscad.splitties:splitties-views:$splitties_version")
  175. //room
  176. implementation("androidx.room:room-runtime:$room_version")
  177. implementation("androidx.room:room-ktx:$room_version")
  178. kapt("androidx.room:room-compiler:$room_version")
  179. androidTestImplementation("androidx.room:room-testing:$room_version")
  180. //liveEventBus
  181. implementation('io.github.jeremyliao:live-event-bus-x:1.8.0')
  182. //规则相关
  183. implementation('org.jsoup:jsoup:1.15.3')
  184. implementation('com.jayway.jsonpath:json-path:2.7.0')
  185. implementation('cn.wanghaomiao:JsoupXpath:2.5.1')
  186. implementation(project(path: ':epublib'))
  187. //JS rhino
  188. //implementation('com.github.gedoor:rhino-android:1.8')
  189. implementation(fileTree(dir: 'lib', include: ['rhino-*.jar']))
  190. //网络
  191. implementation('com.squareup.okhttp3:okhttp:4.10.0')
  192. implementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
  193. //Glide
  194. def glideVersion = "4.14.1"
  195. implementation("com.github.bumptech.glide:glide:$glideVersion")
  196. kapt("com.github.bumptech.glide:compiler:$glideVersion")
  197. //webServer
  198. def nanoHttpdVersion = "2.3.1"
  199. implementation("org.nanohttpd:nanohttpd:$nanoHttpdVersion")
  200. implementation("org.nanohttpd:nanohttpd-websocket:$nanoHttpdVersion")
  201. //二维码
  202. implementation('com.github.jenly1314:zxing-lite:2.2.1')
  203. //颜色选择
  204. implementation('com.jaredrummler:colorpicker:1.1.0')
  205. //apache
  206. implementation('org.apache.commons:commons-text:1.10.0')
  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.7')
  215. //加解密类库,有些书源使用
  216. //noinspection GradleDependency,GradlePackageUpdate
  217. implementation('cn.hutool:hutool-crypto:5.8.8')
  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. }