build.gradle 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. // Gradle build file
  2. //
  3. // This project was started in Eclipse and later moved to Android Studio. In the transition, both IDEs were supported.
  4. // Due to this, the files layout is not the usual in new projects created with Android Studio / gradle. This file
  5. // merges declarations usually split in two separates build.gradle file, one for global settings of the project in
  6. // its root folder, another one for the app module in subfolder of root.
  7. buildscript {
  8. repositories {
  9. jcenter()
  10. maven {
  11. url 'https://oss.sonatype.org/content/repositories/snapshots/'
  12. }
  13. google()
  14. }
  15. dependencies {
  16. classpath 'com.android.tools.build:gradle:3.0.1'
  17. classpath 'com.google.gms:google-services:3.0.0'
  18. }
  19. }
  20. apply plugin: 'com.android.application'
  21. apply plugin: 'checkstyle'
  22. apply plugin: 'pmd'
  23. apply plugin: 'findbugs'
  24. configurations.all {
  25. // check for updates every build
  26. resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
  27. }
  28. ext {
  29. supportLibraryVersion = '26.1.0'
  30. googleLibraryVersion = '11.2.2'
  31. androidLibraryVersion = '1.0.40'
  32. travisBuild = System.getenv("TRAVIS") == "true"
  33. // allows for -Dpre-dex=false to be set
  34. preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
  35. }
  36. repositories {
  37. jcenter()
  38. maven { url "https://jitpack.io" }
  39. maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
  40. google()
  41. flatDir {
  42. dirs 'libs'
  43. }
  44. }
  45. // semantic versioning for version code
  46. def versionMajor = 3
  47. def versionMinor = 1
  48. def versionPatch = 0
  49. def versionBuild = 50 // 0-49=Alpha / 50-98=RC / 99=stable
  50. android {
  51. lintOptions {
  52. abortOnError false
  53. htmlReport true
  54. htmlOutput file("$project.buildDir/reports/lint/lint.html")
  55. disable 'MissingTranslation'
  56. }
  57. dexOptions {
  58. javaMaxHeapSize "4g"
  59. }
  60. compileSdkVersion 26
  61. buildToolsVersion '26.0.2'
  62. defaultConfig {
  63. minSdkVersion 14
  64. targetSdkVersion 26
  65. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  66. // arguments to be passed to functional tests
  67. testInstrumentationRunnerArgument "TEST_USER", "\"$System.env.OCTEST_APP_USERNAME\""
  68. testInstrumentationRunnerArgument "TEST_PASSWORD", "\"$System.env.OCTEST_APP_PASSWORD\""
  69. testInstrumentationRunnerArgument "TEST_SERVER_URL", "\"$System.env.OCTEST_SERVER_BASE_URL\""
  70. multiDexEnabled true
  71. versionCode versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
  72. if (versionBuild > 98) {
  73. versionName "${versionMajor}.${versionMinor}.${versionPatch}"
  74. } else if (versionBuild > 49) {
  75. versionName "${versionMajor}.${versionMinor}.${versionPatch} RC"+(versionBuild-49)
  76. } else {
  77. versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha"+(versionBuild+1)
  78. }
  79. // adapt structure from Eclipse to Gradle/Android Studio expectations;
  80. // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
  81. flavorDimensions "default"
  82. productFlavors {
  83. // used for f-droid
  84. generic {
  85. applicationId 'com.nextcloud.client'
  86. dimension "default"
  87. }
  88. gplay {
  89. applicationId 'com.nextcloud.client'
  90. dimension "default"
  91. }
  92. versionDev {
  93. applicationId "com.nextcloud.android.beta"
  94. dimension "default"
  95. versionCode 20180323
  96. versionName "20180323"
  97. }
  98. }
  99. }
  100. // adapt structure from Eclipse to Gradle/Android Studio expectations;
  101. // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
  102. dexOptions {
  103. // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
  104. preDexLibraries = preDexEnabled && !travisBuild
  105. }
  106. packagingOptions {
  107. exclude 'META-INF/LICENSE.txt'
  108. exclude 'META-INF/LICENSE'
  109. }
  110. task checkstyle(type: Checkstyle) {
  111. configFile = file("${rootProject.projectDir}/checkstyle.xml")
  112. configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
  113. source 'src'
  114. include '**/*.java'
  115. exclude '**/gen/**'
  116. classpath = files()
  117. }
  118. task pmd(type: Pmd) {
  119. ruleSetFiles = files("${project.rootDir}/pmd-ruleset.xml")
  120. ignoreFailures = false
  121. ruleSets = []
  122. source 'src'
  123. include '**/*.java'
  124. exclude '**/gen/**'
  125. reports {
  126. xml.enabled = false
  127. html.enabled = true
  128. xml {
  129. destination = file("$project.buildDir/reports/pmd/pmd.xml")
  130. }
  131. html {
  132. destination = file("$project.buildDir/reports/pmd/pmd.html")
  133. }
  134. }
  135. }
  136. task findbugs(type: FindBugs) {
  137. ignoreFailures = false
  138. effort = "max"
  139. reportLevel = "high"
  140. classes = files("$project.buildDir/intermediates/classes")
  141. excludeFilter = new File("${project.rootDir}/findbugs-filter.xml")
  142. source 'src'
  143. include '**/*.java'
  144. exclude '**/gen/**'
  145. reports {
  146. xml.enabled = false
  147. html.enabled = true
  148. html {
  149. destination = file("$project.buildDir/reports/findbugs/findbugs.html")
  150. }
  151. }
  152. classpath = files()
  153. }
  154. check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
  155. compileOptions {
  156. sourceCompatibility JavaVersion.VERSION_1_8
  157. targetCompatibility JavaVersion.VERSION_1_8
  158. }
  159. }
  160. dependencies {
  161. // dependencies for app building
  162. implementation 'com.android.support:multidex:1.0.2'
  163. // implementation project('nextcloud-android-library')
  164. genericImplementation "com.github.nextcloud:android-library:${androidLibraryVersion}"
  165. gplayImplementation "com.github.nextcloud:android-library:${androidLibraryVersion}"
  166. versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' // use always latest master
  167. implementation "com.android.support:support-v4:${supportLibraryVersion}"
  168. implementation "com.android.support:design:${supportLibraryVersion}"
  169. implementation 'com.jakewharton:disklrucache:2.0.2'
  170. implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
  171. implementation "com.android.support:cardview-v7:${supportLibraryVersion}"
  172. implementation "com.android.support:exifinterface:${supportLibraryVersion}"
  173. implementation 'com.github.tobiasKaminsky:android-floating-action-button:1.10.2'
  174. implementation 'com.github.albfernandez:juniversalchardet:v2.0.0'
  175. implementation 'com.google.code.findbugs:annotations:2.0.1'
  176. implementation 'commons-io:commons-io:2.5'
  177. implementation 'com.github.evernote:android-job:v1.2.5'
  178. implementation 'com.jakewharton:butterknife:8.8.1'
  179. annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
  180. implementation 'org.greenrobot:eventbus:3.0.0'
  181. implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.2'
  182. implementation 'org.lukhnos:nnio:0.2'
  183. implementation 'com.madgag.spongycastle:pkix:1.54.0.0'
  184. implementation 'com.google.code.gson:gson:2.8.2'
  185. // uncomment for gplay
  186. // implementation "com.google.firebase:firebase-messaging:${googleLibraryVersion}"
  187. // implementation "com.google.android.gms:play-services-base:${googleLibraryVersion}"
  188. // implementation "com.google.android.gms:play-services-gcm:${googleLibraryVersion}"
  189. // implementation "com.google.firebase:firebase-core:${googleLibraryVersion}"
  190. implementation 'org.parceler:parceler-api:1.1.9'
  191. annotationProcessor 'org.parceler:parceler:1.1.9'
  192. implementation 'com.github.bumptech.glide:glide:3.7.0'
  193. implementation 'com.caverock:androidsvg:1.2.1'
  194. implementation "com.android.support:support-annotations:${supportLibraryVersion}"
  195. implementation 'com.google.code.gson:gson:2.8.2'
  196. // dependencies for local unit tests
  197. testImplementation 'junit:junit:4.12'
  198. testImplementation 'org.mockito:mockito-core:1.10.19'
  199. // dependencies for instrumented tests
  200. // JUnit4 Rules
  201. androidTestImplementation 'com.android.support.test:rules:1.0.1'
  202. // Android JUnit Runner
  203. androidTestImplementation 'com.android.support.test:runner:1.0.1'
  204. // Espresso core
  205. androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  206. androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.1'
  207. // UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
  208. androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
  209. // fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
  210. //androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
  211. implementation 'org.jetbrains:annotations:15.0'
  212. androidTestCompile 'tools.fastlane:screengrab:1.0.0'
  213. }
  214. configurations.all {
  215. resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
  216. }
  217. tasks.withType(Test) {
  218. // increased logging for tests
  219. testLogging {
  220. events "passed", "skipped", "failed"
  221. }
  222. }
  223. // uncomment for gplay (must be at the bottom)
  224. //apply plugin: 'com.google.gms.google-services'