build.gradle 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. plugins {
  2. id "com.android.application"
  3. id 'org.jetbrains.kotlin.android'
  4. id 'kotlin-parcelize'
  5. id 'kotlin-kapt'
  6. id "de.timfreiheit.resourceplaceholders"
  7. //id "com.google.gms.google-services"
  8. }
  9. apply from: 'download.gradle'
  10. static def releaseTime() {
  11. return new Date().format("yy.MMddHH", TimeZone.getTimeZone("GMT+8"))
  12. }
  13. def name = "legado"
  14. def version = "3." + releaseTime()
  15. def gitCommits = Integer.parseInt('git rev-list HEAD --count'.execute().text.trim())
  16. android {
  17. compileSdkVersion 32
  18. buildToolsVersion "32.0.0"
  19. namespace 'io.legado.app'
  20. kotlinOptions {
  21. jvmTarget = "11"
  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. minSdkVersion 21
  40. targetSdkVersion 32
  41. versionCode 10000 + gitCommits
  42. versionName version
  43. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  44. project.ext.set("archivesBaseName", name + "_" + version)
  45. multiDexEnabled true
  46. javaCompileOptions {
  47. annotationProcessorOptions {
  48. arguments += [
  49. "room.incremental" : "true",
  50. "room.expandProjection": "true",
  51. "room.schemaLocation" : "$projectDir/schemas".toString()
  52. ]
  53. }
  54. }
  55. }
  56. buildFeatures {
  57. viewBinding true
  58. compose true
  59. }
  60. buildTypes {
  61. release {
  62. buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
  63. if (project.hasProperty("RELEASE_STORE_FILE")) {
  64. signingConfig signingConfigs.myConfig
  65. }
  66. applicationIdSuffix '.release'
  67. minifyEnabled false
  68. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  69. }
  70. debug {
  71. buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
  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. 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. }
  87. flavorDimensions "mode"
  88. productFlavors {
  89. app {
  90. dimension "mode"
  91. manifestPlaceholders = [APP_CHANNEL_VALUE: "app"]
  92. }
  93. google {
  94. dimension "mode"
  95. applicationId "io.legado.play"
  96. manifestPlaceholders = [APP_CHANNEL_VALUE: "google"]
  97. }
  98. }
  99. compileOptions {
  100. // Flag to enable support for the new language APIs
  101. coreLibraryDesugaringEnabled true
  102. // Sets Java compatibility to Java 11
  103. sourceCompatibility JavaVersion.VERSION_11
  104. targetCompatibility JavaVersion.VERSION_11
  105. }
  106. composeOptions {
  107. kotlinCompilerExtensionVersion "$compose_compiler_version"
  108. }
  109. sourceSets {
  110. // Adds exported schema location as test app assets.
  111. androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
  112. }
  113. lint {
  114. checkDependencies true
  115. }
  116. tasks.withType(JavaCompile) {
  117. //options.compilerArgs << "-Xlint:unchecked"
  118. }
  119. }
  120. resourcePlaceholders {
  121. files = ['xml/shortcuts.xml']
  122. }
  123. kapt {
  124. arguments {
  125. arg("room.schemaLocation", "$projectDir/schemas")
  126. }
  127. }
  128. dependencies {
  129. //noinspection GradleDependency
  130. coreLibraryDesugaring('com.android.tools:desugar_jdk_libs:1.1.6')
  131. testImplementation('junit:junit:4.13.2')
  132. androidTestImplementation('androidx.test:runner:1.4.0')
  133. androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0')
  134. implementation('androidx.multidex:multidex:2.0.1')
  135. //kotlin
  136. //noinspection GradleDependency
  137. //noinspection DifferentStdlibGradleVersion
  138. implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
  139. //Kotlin反射
  140. //noinspection GradleDependency
  141. implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
  142. //协程
  143. def coroutines_version = '1.6.3-native-mt'
  144. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
  145. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
  146. //图像处理库Toolkit
  147. implementation('com.github.android:renderscript-intrinsics-replacement-toolkit:b6363490c3')
  148. //androidX
  149. implementation('androidx.core:core-ktx:1.8.0')
  150. implementation('androidx.appcompat:appcompat:1.4.2')
  151. implementation('androidx.activity:activity-ktx:1.5.0')
  152. implementation('androidx.fragment:fragment-ktx:1.5.0')
  153. implementation('androidx.preference:preference-ktx:1.2.0')
  154. implementation('androidx.constraintlayout:constraintlayout:2.1.4')
  155. implementation('androidx.swiperefreshlayout:swiperefreshlayout:1.1.0')
  156. implementation('androidx.viewpager2:viewpager2:1.0.0')
  157. implementation('androidx.webkit:webkit:1.4.0')
  158. //google
  159. implementation('com.google.android.material:material:1.6.1')
  160. implementation('com.google.android.flexbox:flexbox:3.0.0')
  161. implementation('com.google.code.gson:gson:2.9.0')
  162. //lifecycle
  163. def lifecycle_version = '2.5.0'
  164. implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version")
  165. //compose
  166. // Integration with activities
  167. implementation 'androidx.activity:activity-compose:1.5.0'
  168. // Compose Material Design
  169. implementation "androidx.compose.material:material:$compose_version"
  170. // Animations
  171. implementation "androidx.compose.animation:animation:$compose_version"
  172. // Tooling support (Previews, etc.)
  173. implementation "androidx.compose.ui:ui-tooling:$compose_version"
  174. // UI Tests
  175. androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
  176. //media
  177. implementation("androidx.media:media:1.6.0")
  178. implementation("com.google.android.exoplayer:exoplayer-core:$exoplayer_version")
  179. implementation("com.google.android.exoplayer:extension-okhttp:$exoplayer_version")
  180. //Splitties
  181. implementation("com.louiscad.splitties:splitties-appctx:$splitties_version")
  182. implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version")
  183. implementation("com.louiscad.splitties:splitties-views:$splitties_version")
  184. //room
  185. implementation("androidx.room:room-runtime:$room_version")
  186. implementation("androidx.room:room-ktx:$room_version")
  187. kapt("androidx.room:room-compiler:$room_version")
  188. //ksp("androidx.room:room-compiler:$room_version")
  189. testImplementation("androidx.room:room-testing:$room_version")
  190. //liveEventBus
  191. implementation('io.github.jeremyliao:live-event-bus-x:1.8.0')
  192. //规则相关
  193. implementation('org.jsoup:jsoup:1.15.2')
  194. implementation('com.jayway.jsonpath:json-path:2.7.0')
  195. implementation('cn.wanghaomiao:JsoupXpath:2.5.1')
  196. implementation(project(path: ':epublib'))
  197. //JS rhino
  198. //implementation('com.github.gedoor:rhino-android:1.8')
  199. implementation(fileTree(dir: 'lib', include: ['rhino-*.jar']))
  200. //网络
  201. implementation('com.squareup.okhttp3:okhttp:4.10.0')
  202. implementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
  203. //Glide
  204. def glideVersion = "4.13.2"
  205. implementation("com.github.bumptech.glide:glide:$glideVersion")
  206. kapt("com.github.bumptech.glide:compiler:$glideVersion")
  207. //webServer
  208. def nanoHttpdVersion = "2.3.1"
  209. implementation("org.nanohttpd:nanohttpd:$nanoHttpdVersion")
  210. implementation("org.nanohttpd:nanohttpd-websocket:$nanoHttpdVersion")
  211. //二维码
  212. implementation('com.github.jenly1314:zxing-lite:2.2.1')
  213. //颜色选择
  214. implementation('com.jaredrummler:colorpicker:1.1.0')
  215. //apache
  216. implementation('org.apache.commons:commons-text:1.9')
  217. //MarkDown
  218. def markwonVersion = "4.6.2"
  219. implementation("io.noties.markwon:core:$markwonVersion")
  220. implementation("io.noties.markwon:image-glide:$markwonVersion")
  221. implementation("io.noties.markwon:ext-tables:$markwonVersion")
  222. implementation("io.noties.markwon:html:$markwonVersion")
  223. //转换繁体
  224. implementation('com.github.liuyueyi.quick-chinese-transfer:quick-transfer-core:0.2.5')
  225. //加解密类库,有些书源使用
  226. //noinspection GradleDependency
  227. implementation('cn.hutool:hutool-crypto:5.8.1')
  228. //firebase, 崩溃统计和性能统计, 会导致共存版本崩溃
  229. //implementation platform('com.google.firebase:firebase-bom:30.0.1')
  230. //implementation 'com.google.firebase:firebase-analytics-ktx:21.0.0'
  231. //implementation 'com.google.firebase:firebase-perf-ktx:20.0.6'
  232. // LeakCanary
  233. //debugImplementation('com.squareup.leakcanary:leakcanary-android:2.7')
  234. //com.github.AmrDeveloper:CodeView代码编辑已集成到应用内
  235. //epubLib集成到应用内
  236. }