build.gradle 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. apply plugin: 'com.android.application'
  2. apply plugin: 'kotlin-android'
  3. apply plugin: 'kotlin-parcelize'
  4. apply plugin: 'kotlin-kapt'
  5. apply plugin: 'de.timfreiheit.resourceplaceholders'
  6. apply from: 'download.gradle'
  7. static def releaseTime() {
  8. return new Date().format("yy.MMddHH", TimeZone.getTimeZone("GMT+8"))
  9. }
  10. def name = "legado"
  11. def version = "3." + releaseTime()
  12. def gitCommits = Integer.parseInt('git rev-list --count HEAD'.execute([], project.rootDir).text.trim())
  13. android {
  14. compileSdkVersion 31
  15. buildToolsVersion '31.0.0'
  16. kotlinOptions {
  17. jvmTarget = "11"
  18. }
  19. signingConfigs {
  20. if (project.hasProperty("RELEASE_STORE_FILE")) {
  21. myConfig {
  22. storeFile file(RELEASE_STORE_FILE)
  23. storePassword RELEASE_STORE_PASSWORD
  24. keyAlias RELEASE_KEY_ALIAS
  25. keyPassword RELEASE_KEY_PASSWORD
  26. v1SigningEnabled true
  27. v2SigningEnabled true
  28. }
  29. }
  30. }
  31. defaultConfig {
  32. applicationId "io.legado.app"
  33. minSdkVersion 21
  34. targetSdkVersion 31
  35. versionCode 10000 + gitCommits
  36. versionName version
  37. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  38. project.ext.set("archivesBaseName", name + "_" + version)
  39. multiDexEnabled true
  40. javaCompileOptions {
  41. annotationProcessorOptions {
  42. arguments += [
  43. "room.incremental" : "true",
  44. "room.expandProjection": "true",
  45. "room.schemaLocation" : "$projectDir/schemas".toString()
  46. ]
  47. }
  48. }
  49. }
  50. buildFeatures {
  51. viewBinding true
  52. }
  53. buildTypes {
  54. release {
  55. buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
  56. if (project.hasProperty("RELEASE_STORE_FILE")) {
  57. signingConfig signingConfigs.myConfig
  58. }
  59. applicationIdSuffix '.release'
  60. minifyEnabled false
  61. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  62. }
  63. debug {
  64. buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
  65. if (project.hasProperty("RELEASE_STORE_FILE")) {
  66. signingConfig signingConfigs.myConfig
  67. }
  68. applicationIdSuffix '.debug'
  69. versionNameSuffix 'debug'
  70. minifyEnabled false
  71. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  72. }
  73. android.applicationVariants.all { variant ->
  74. variant.outputs.all {
  75. def flavor = variant.productFlavors[0].name
  76. outputFileName = "${name}_${flavor}_${defaultConfig.versionName}.apk"
  77. }
  78. }
  79. }
  80. flavorDimensions "mode"
  81. productFlavors {
  82. app {
  83. dimension "mode"
  84. manifestPlaceholders = [APP_CHANNEL_VALUE: "app"]
  85. }
  86. google {
  87. dimension "mode"
  88. applicationId "io.legado.play"
  89. manifestPlaceholders = [APP_CHANNEL_VALUE: "google"]
  90. }
  91. }
  92. compileOptions {
  93. // Flag to enable support for the new language APIs
  94. coreLibraryDesugaringEnabled true
  95. // Sets Java compatibility to Java 11
  96. sourceCompatibility JavaVersion.VERSION_11
  97. targetCompatibility JavaVersion.VERSION_11
  98. }
  99. sourceSets {
  100. // Adds exported schema location as test app assets.
  101. androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
  102. }
  103. tasks.withType(JavaCompile) {
  104. //options.compilerArgs << "-Xlint:unchecked"
  105. }
  106. }
  107. resourcePlaceholders {
  108. files = ['xml/shortcuts.xml']
  109. }
  110. kapt {
  111. arguments {
  112. arg("room.schemaLocation", "$projectDir/schemas")
  113. }
  114. }
  115. dependencies {
  116. coreLibraryDesugaring('com.android.tools:desugar_jdk_libs:1.1.5')
  117. testImplementation('junit:junit:4.13.2')
  118. androidTestImplementation('androidx.test:runner:1.4.0')
  119. androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0')
  120. implementation('androidx.multidex:multidex:2.0.1')
  121. //kotlin
  122. implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
  123. //Kotlin反射
  124. implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
  125. //协程
  126. def coroutines_version = '1.6.0'
  127. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
  128. implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")
  129. //androidX
  130. implementation('androidx.core:core-ktx:1.7.0')
  131. implementation('androidx.appcompat:appcompat:1.4.1')
  132. implementation('androidx.activity:activity-ktx:1.4.0')
  133. implementation('androidx.fragment:fragment-ktx:1.4.1')
  134. implementation('androidx.preference:preference-ktx:1.2.0')
  135. implementation('androidx.constraintlayout:constraintlayout:2.1.3')
  136. implementation('androidx.swiperefreshlayout:swiperefreshlayout:1.1.0')
  137. implementation('androidx.viewpager2:viewpager2:1.0.0')
  138. implementation('com.google.android.material:material:1.5.0')
  139. implementation('com.google.android.flexbox:flexbox:3.0.0')
  140. implementation('com.google.code.gson:gson:2.8.9')
  141. implementation('androidx.webkit:webkit:1.4.0')
  142. implementation('com.jakewharton.timber:timber:5.0.1')
  143. //media
  144. implementation("androidx.media:media:1.4.3")
  145. def exoplayer_version = '2.16.1'
  146. implementation("com.google.android.exoplayer:exoplayer-core:$exoplayer_version")
  147. implementation("com.google.android.exoplayer:extension-okhttp:$exoplayer_version")
  148. //Splitties
  149. def splitties_version = '3.0.0'
  150. implementation("com.louiscad.splitties:splitties-appctx:$splitties_version")
  151. implementation("com.louiscad.splitties:splitties-systemservices:$splitties_version")
  152. implementation("com.louiscad.splitties:splitties-views:$splitties_version")
  153. //lifecycle
  154. def lifecycle_version = '2.4.0'
  155. implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycle_version")
  156. //room
  157. def room_version = '2.4.1'
  158. implementation("androidx.room:room-runtime:$room_version")
  159. implementation("androidx.room:room-ktx:$room_version")
  160. kapt("androidx.room:room-compiler:$room_version")
  161. testImplementation("androidx.room:room-testing:$room_version")
  162. //liveEventBus
  163. implementation('io.github.jeremyliao:live-event-bus-x:1.8.0')
  164. //规则相关
  165. implementation('org.jsoup:jsoup:1.14.3')
  166. implementation('com.jayway.jsonpath:json-path:2.7.0')
  167. implementation('cn.wanghaomiao:JsoupXpath:2.5.1')
  168. implementation(project(path: ':epublib'))
  169. //JS rhino
  170. implementation('com.github.gedoor:rhino-android:1.6')
  171. //网络
  172. implementation('com.squareup.okhttp3:okhttp:4.9.3')
  173. implementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
  174. //Glide
  175. implementation('com.github.bumptech.glide:glide:4.12.0')
  176. kapt('com.github.bumptech.glide:compiler:4.12.0')
  177. //webServer
  178. def nanoHttpdVersion = "2.3.1"
  179. implementation("org.nanohttpd:nanohttpd:$nanoHttpdVersion")
  180. implementation("org.nanohttpd:nanohttpd-websocket:$nanoHttpdVersion")
  181. //二维码
  182. implementation('com.github.jenly1314:zxing-lite:2.1.1')
  183. //颜色选择
  184. implementation('com.jaredrummler:colorpicker:1.1.0')
  185. //apache
  186. implementation('org.apache.commons:commons-text:1.9')
  187. //MarkDown
  188. def markwonVersion = "4.6.2"
  189. implementation("io.noties.markwon:core:$markwonVersion")
  190. implementation("io.noties.markwon:image-glide:$markwonVersion")
  191. implementation("io.noties.markwon:ext-tables:$markwonVersion")
  192. implementation("io.noties.markwon:html:$markwonVersion")
  193. //转换繁体
  194. implementation('com.github.liuyueyi.quick-chinese-transfer:quick-transfer-core:0.2.3')
  195. //加解密类库
  196. implementation('cn.hutool:hutool-crypto:5.7.20')
  197. //代码编辑com.github.AmrDeveloper:CodeView已集成到应用内
  198. //epubLib集成到应用内
  199. // LeakCanary
  200. //debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
  201. }