build.gradle 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. import java.text.SimpleDateFormat
  2. apply plugin: 'com.android.application'
  3. apply plugin: 'kotlin-android'
  4. apply plugin: 'kotlin-android-extensions'
  5. if (file("custom.gradle").exists()) {
  6. apply from: "custom.gradle"
  7. }
  8. ext {
  9. // Git is needed in your system PATH for these commands to work.
  10. // If it's not installed, you can return a random value as a workaround
  11. getCommitCount = {
  12. return 'git rev-list --count HEAD'.execute().text.trim()
  13. // return "1"
  14. }
  15. getGitSha = {
  16. return 'git rev-parse --short HEAD'.execute().text.trim()
  17. // return "1"
  18. }
  19. getBuildTime = {
  20. def df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")
  21. df.setTimeZone(TimeZone.getTimeZone("UTC"))
  22. return df.format(new Date())
  23. }
  24. }
  25. android {
  26. compileSdkVersion 25
  27. buildToolsVersion "25.0.2"
  28. publishNonDefault true
  29. defaultConfig {
  30. applicationId "eu.kanade.tachiyomi"
  31. minSdkVersion 16
  32. targetSdkVersion 25
  33. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  34. versionCode 22
  35. versionName "0.5.2"
  36. buildConfigField "String", "COMMIT_COUNT", "\"${getCommitCount()}\""
  37. buildConfigField "String", "COMMIT_SHA", "\"${getGitSha()}\""
  38. buildConfigField "String", "BUILD_TIME", "\"${getBuildTime()}\""
  39. buildConfigField "boolean", "INCLUDE_UPDATER", "false"
  40. vectorDrawables.useSupportLibrary = true
  41. ndk {
  42. abiFilters "armeabi-v7a", "arm64-v8a", "x86"
  43. }
  44. }
  45. buildTypes {
  46. debug {
  47. versionNameSuffix "-${getCommitCount()}"
  48. applicationIdSuffix ".debug"
  49. multiDexEnabled true
  50. }
  51. release {
  52. minifyEnabled true
  53. shrinkResources true
  54. multiDexEnabled false
  55. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  56. }
  57. }
  58. productFlavors {
  59. standard {
  60. buildConfigField "boolean", "INCLUDE_UPDATER", "true"
  61. }
  62. fdroid {
  63. }
  64. dev {
  65. minSdkVersion 21
  66. resConfigs "en", "xxhdpi"
  67. }
  68. }
  69. packagingOptions {
  70. exclude 'META-INF/DEPENDENCIES'
  71. exclude 'LICENSE.txt'
  72. exclude 'META-INF/LICENSE'
  73. exclude 'META-INF/LICENSE.txt'
  74. exclude 'META-INF/NOTICE'
  75. }
  76. lintOptions {
  77. abortOnError false
  78. checkReleaseBuilds false
  79. }
  80. sourceSets {
  81. main.java.srcDirs += 'src/main/kotlin'
  82. }
  83. }
  84. dependencies {
  85. compile "com.bluelinelabs:conductor:2.1.3"
  86. final rxbindings_version = '1.0.1'
  87. compile "com.jakewharton.rxbinding:rxbinding-kotlin:$rxbindings_version"
  88. compile "com.jakewharton.rxbinding:rxbinding-appcompat-v7-kotlin:$rxbindings_version"
  89. compile "com.jakewharton.rxbinding:rxbinding-support-v4-kotlin:$rxbindings_version"
  90. compile "com.jakewharton.rxbinding:rxbinding-recyclerview-v7-kotlin:$rxbindings_version"
  91. compile 'com.nightlynexus.viewstatepageradapter:viewstatepageradapter:1.0.4'
  92. // Modified dependencies
  93. compile 'com.github.inorichi:subsampling-scale-image-view:01e5385'
  94. compile 'com.github.inorichi:junrar-android:634c1f5'
  95. // Android support library
  96. final support_library_version = '25.3.1'
  97. compile "com.android.support:support-v4:$support_library_version"
  98. compile "com.android.support:appcompat-v7:$support_library_version"
  99. compile "com.android.support:cardview-v7:$support_library_version"
  100. compile "com.android.support:design:$support_library_version"
  101. compile "com.android.support:recyclerview-v7:$support_library_version"
  102. compile "com.android.support:support-annotations:$support_library_version"
  103. compile "com.android.support:customtabs:$support_library_version"
  104. compile 'com.android.support.constraint:constraint-layout:1.0.2'
  105. compile 'com.android.support:multidex:1.0.1'
  106. // ReactiveX
  107. compile 'io.reactivex:rxandroid:1.2.1'
  108. compile 'io.reactivex:rxjava:1.2.9'
  109. compile 'com.jakewharton.rxrelay:rxrelay:1.2.0'
  110. compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.2'
  111. compile 'com.github.pwittchen:reactivenetwork:0.7.0'
  112. // Network client
  113. compile "com.squareup.okhttp3:okhttp:3.6.0"
  114. compile 'com.squareup.okio:okio:1.11.0'
  115. // REST
  116. final retrofit_version = '2.2.0'
  117. compile "com.squareup.retrofit2:retrofit:$retrofit_version"
  118. compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
  119. compile "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
  120. // JSON
  121. compile 'com.google.code.gson:gson:2.8.0'
  122. compile 'com.github.salomonbrys.kotson:kotson:2.5.0'
  123. // YAML
  124. compile 'com.github.bmoliveira:snake-yaml:v1.18-android'
  125. // JavaScript engine
  126. compile 'com.squareup.duktape:duktape-android:1.1.0'
  127. // Disk
  128. compile 'com.jakewharton:disklrucache:2.0.2'
  129. compile 'com.github.seven332:unifile:1.0.0'
  130. // HTML parser
  131. compile 'org.jsoup:jsoup:1.10.2'
  132. // Job scheduling
  133. compile 'com.evernote:android-job:1.1.8'
  134. compile 'com.google.android.gms:play-services-gcm:10.2.0'
  135. // Changelog
  136. compile 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0'
  137. // Database
  138. compile "com.pushtorefresh.storio:sqlite:1.12.3"
  139. // Model View Presenter
  140. final nucleus_version = '3.0.0'
  141. compile "info.android15.nucleus:nucleus:$nucleus_version"
  142. compile "info.android15.nucleus:nucleus-support-v4:$nucleus_version"
  143. compile "info.android15.nucleus:nucleus-support-v7:$nucleus_version"
  144. // Dependency injection
  145. compile "uy.kohesive.injekt:injekt-core:1.16.1"
  146. // Image library
  147. compile 'com.github.bumptech.glide:glide:3.7.0'
  148. compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
  149. // Transformations
  150. compile 'jp.wasabeef:glide-transformations:2.0.2'
  151. // Logging
  152. compile 'com.jakewharton.timber:timber:4.5.1'
  153. // Crash reports
  154. compile 'ch.acra:acra:4.9.2'
  155. // Sort
  156. compile 'com.github.gpanther:java-nat-sort:natural-comparator-1.1'
  157. // UI
  158. compile 'com.dmitrymalkovich.android:material-design-dimens:1.4'
  159. compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
  160. compile 'eu.davidea:flexible-adapter:5.0.0-rc1'
  161. compile 'com.github.inorichi:FlexibleAdapter:93985fe' // v4.2.0 to be removed
  162. compile 'com.nononsenseapps:filepicker:2.5.2'
  163. compile 'com.github.amulyakhare:TextDrawable:558677e'
  164. compile 'com.afollestad.material-dialogs:core:0.9.4.2'
  165. compile 'net.xpece.android:support-preference:1.2.5'
  166. compile 'me.zhanghai.android.systemuihelper:library:1.0.0'
  167. compile 'de.hdodenhof:circleimageview:2.1.0'
  168. // Tests
  169. testCompile 'junit:junit:4.12'
  170. testCompile 'org.assertj:assertj-core:1.7.1'
  171. testCompile 'org.mockito:mockito-core:1.10.19'
  172. final robolectric_version = '3.1.4'
  173. testCompile "org.robolectric:robolectric:$robolectric_version"
  174. testCompile "org.robolectric:shadows-multidex:$robolectric_version"
  175. testCompile "org.robolectric:shadows-play-services:$robolectric_version"
  176. compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  177. }
  178. buildscript {
  179. ext.kotlin_version = '1.1.2'
  180. repositories {
  181. mavenCentral()
  182. }
  183. dependencies {
  184. classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  185. }
  186. }
  187. repositories {
  188. mavenCentral()
  189. }
  190. // Workaround to force a support lib version
  191. configurations.all {
  192. resolutionStrategy.eachDependency { details ->
  193. def requested = details.requested
  194. if (requested.group == 'com.android.support') {
  195. if (!requested.name.startsWith("multidex")) {
  196. details.useVersion '25.3.1'
  197. }
  198. }
  199. }
  200. }
  201. // add support for placeholders in resource files
  202. //https://code.google.com/p/android/issues/detail?id=69224
  203. def replacePlaceholdersInFile(basePath, fileName, placeholders) {
  204. def file = new File(basePath, fileName);
  205. if (!file.exists()) {
  206. logger.quiet("Unable to replace placeholders in " + file.toString() + ". File cannot be found.")
  207. return;
  208. }
  209. logger.debug("Replacing placeholders in " + file.toString())
  210. logger.debug("Placeholders: " + placeholders.toString())
  211. def content = file.getText('UTF-8')
  212. placeholders.each { entry ->
  213. content = content.replaceAll("\\\$\\{${entry.key}\\}", entry.value)
  214. }
  215. file.write(content, 'UTF-8')
  216. }
  217. afterEvaluate {
  218. android.applicationVariants.all { variant ->
  219. variant.outputs.each { output ->
  220. output.processResources.doFirst {
  221. // prepare placeholder map from manifestPlaceholders including applicationId placeholder
  222. def placeholders = variant.mergedFlavor.manifestPlaceholders + [applicationId: variant.applicationId]
  223. replacePlaceholdersInFile(resDir, 'xml-v25/shortcuts.xml', placeholders)
  224. }
  225. }
  226. }
  227. }