build.gradle 9.2 KB

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