build.gradle 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. compileSdkVersion 33
  17. buildToolsVersion "33.0.0"
  18. namespace 'io.legado.app'
  19. kotlinOptions {
  20. jvmTarget = "11"
  21. }
  22. signingConfigs {
  23. if (project.hasProperty("RELEASE_STORE_FILE")) {
  24. myConfig {
  25. storeFile file(RELEASE_STORE_FILE)
  26. storePassword RELEASE_STORE_PASSWORD
  27. keyAlias RELEASE_KEY_ALIAS
  28. keyPassword RELEASE_KEY_PASSWORD
  29. v1SigningEnabled true
  30. v2SigningEnabled true
  31. enableV3Signing = true
  32. enableV4Signing = true
  33. }
  34. }
  35. }
  36. defaultConfig {
  37. applicationId "io.legado.app"
  38. minSdkVersion 21
  39. targetSdkVersion 33
  40. versionCode 10000 + gitCommits
  41. versionName version
  42. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  43. project.ext.set("archivesBaseName", name + "_" + version)
  44. multiDexEnabled true
  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. viewBinding true
  57. compose true
  58. }
  59. buildTypes {
  60. release {
  61. buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
  62. if (project.hasProperty("RELEASE_STORE_FILE")) {
  63. signingConfig signingConfigs.myConfig
  64. }
  65. applicationIdSuffix '.release'
  66. minifyEnabled false
  67. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  68. }
  69. debug {
  70. buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
  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. 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. }
  86. flavorDimensions "mode"
  87. productFlavors {
  88. app {
  89. dimension "mode"
  90. manifestPlaceholders = [APP_CHANNEL_VALUE: "app"]
  91. }
  92. google {
  93. dimension "mode"
  94. applicationId "io.legado.play"
  95. manifestPlaceholders = [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. //noinspection GradleDependency,GradlePackageUpdate
  121. coreLibraryDesugaring('com.android.tools:desugar_jdk_libs:1.2.2')
  122. testImplementation('junit:junit:4.13.2')
  123. androidTestImplementation('androidx.test:runner:1.4.0')
  124. androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0')
  125. implementation('androidx.multidex:multidex:2.0.1')
  126. //kotlin
  127. //noinspection GradleDependency,DifferentStdlibGradleVersion
  128. implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
  129. //Kotlin反射
  130. //noinspection GradleDependency,DifferentStdlibGradleVersion
  131. implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
  132. //协程
  133. def coroutines_version = '1.6.4'
  134. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
  135. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
  136. //图像处理库Toolkit
  137. implementation('com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3')
  138. //androidX
  139. implementation('androidx.core:core-ktx:1.9.0')
  140. implementation('androidx.appcompat:appcompat:1.5.1')
  141. implementation('androidx.activity:activity-ktx:1.6.0')
  142. implementation('androidx.fragment:fragment-ktx:1.5.3')
  143. implementation('androidx.preference:preference-ktx:1.2.0')
  144. implementation('androidx.constraintlayout:constraintlayout:2.1.4')
  145. implementation('androidx.swiperefreshlayout:swiperefreshlayout:1.1.0')
  146. implementation('androidx.viewpager2:viewpager2:1.0.0')
  147. implementation('androidx.webkit:webkit:1.5.0')
  148. //google
  149. implementation('com.google.android.material:material:1.6.1')
  150. implementation('com.google.android.flexbox:flexbox:3.0.0')
  151. implementation('com.google.code.gson:gson:2.9.1')
  152. //lifecycle
  153. def lifecycle_version = '2.5.1'
  154. implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version")
  155. //compose
  156. // Integration with activities
  157. implementation 'androidx.activity:activity-compose:1.6.0'
  158. // Compose Material Design
  159. implementation "androidx.compose.material:material:$compose_version"
  160. // Animations
  161. implementation "androidx.compose.animation:animation:$compose_version"
  162. // Tooling support (Previews, etc.)
  163. implementation "androidx.compose.ui:ui-tooling:$compose_version"
  164. // UI Tests
  165. androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
  166. //media
  167. implementation("androidx.media:media:1.6.0")
  168. implementation("com.google.android.exoplayer:exoplayer-core:$exoplayer_version")
  169. implementation("com.google.android.exoplayer:extension-okhttp:$exoplayer_version")
  170. //Splitties
  171. implementation("com.louiscad.splitties:splitties-appctx:$splitties_version")
  172. implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version")
  173. implementation("com.louiscad.splitties:splitties-views:$splitties_version")
  174. //room
  175. implementation("androidx.room:room-runtime:$room_version")
  176. implementation("androidx.room:room-ktx:$room_version")
  177. kapt("androidx.room:room-compiler:$room_version")
  178. androidTestImplementation("androidx.room:room-testing:$room_version")
  179. //liveEventBus
  180. implementation('io.github.jeremyliao:live-event-bus-x:1.8.0')
  181. //规则相关
  182. implementation('org.jsoup:jsoup:1.15.3')
  183. implementation('com.jayway.jsonpath:json-path:2.7.0')
  184. implementation('cn.wanghaomiao:JsoupXpath:2.5.1')
  185. implementation(project(path: ':epublib'))
  186. //JS rhino
  187. //implementation('com.github.gedoor:rhino-android:1.8')
  188. implementation(fileTree(dir: 'lib', include: ['rhino-*.jar']))
  189. //网络
  190. implementation('com.squareup.okhttp3:okhttp:4.10.0')
  191. implementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
  192. //Glide
  193. def glideVersion = "4.14.0"
  194. implementation("com.github.bumptech.glide:glide:$glideVersion")
  195. kapt("com.github.bumptech.glide:compiler:$glideVersion")
  196. //webServer
  197. def nanoHttpdVersion = "2.3.1"
  198. implementation("org.nanohttpd:nanohttpd:$nanoHttpdVersion")
  199. implementation("org.nanohttpd:nanohttpd-websocket:$nanoHttpdVersion")
  200. //二维码
  201. implementation('com.github.jenly1314:zxing-lite:2.2.1')
  202. //颜色选择
  203. implementation('com.jaredrummler:colorpicker:1.1.0')
  204. //apache
  205. implementation('org.apache.commons:commons-text:1.9')
  206. //MarkDown
  207. def markwonVersion = "4.6.2"
  208. implementation("io.noties.markwon:core:$markwonVersion")
  209. implementation("io.noties.markwon:image-glide:$markwonVersion")
  210. implementation("io.noties.markwon:ext-tables:$markwonVersion")
  211. implementation("io.noties.markwon:html:$markwonVersion")
  212. //转换繁体
  213. implementation('com.github.liuyueyi.quick-chinese-transfer:quick-transfer-core:0.2.7')
  214. //加解密类库,有些书源使用
  215. //noinspection GradleDependency,GradlePackageUpdate
  216. implementation('cn.hutool:hutool-crypto:5.8.8')
  217. //firebase, 崩溃统计和性能统计, 会导致共存版本崩溃
  218. //implementation platform('com.google.firebase:firebase-bom:30.0.1')
  219. //implementation 'com.google.firebase:firebase-analytics-ktx:21.0.0'
  220. //implementation 'com.google.firebase:firebase-perf-ktx:20.0.6'
  221. //LeakCanary, 内存泄露检测
  222. //debugImplementation('com.squareup.leakcanary:leakcanary-android:2.7')
  223. //com.github.AmrDeveloper:CodeView代码编辑已集成到应用内
  224. //epubLib集成到应用内
  225. }