build.gradle 9.4 KB

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