build.gradle 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. }
  14. dependencies {
  15. classpath 'com.android.tools.build:gradle:2.2.3'
  16. classpath 'com.google.gms:google-services:3.0.0'
  17. }
  18. }
  19. apply plugin: 'com.android.application'
  20. apply plugin: 'checkstyle'
  21. apply plugin: 'pmd'
  22. apply plugin: 'findbugs'
  23. configurations.all {
  24. // check for updates every build
  25. resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
  26. }
  27. ext {
  28. supportLibraryVersion = '25.2.0'
  29. travisBuild = System.getenv("TRAVIS") == "true"
  30. // allows for -Dpre-dex=false to be set
  31. preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
  32. }
  33. repositories {
  34. jcenter()
  35. maven { url "https://jitpack.io" }
  36. flatDir {
  37. dirs 'libs'
  38. }
  39. }
  40. android {
  41. lintOptions {
  42. abortOnError true
  43. lintConfig file("${project.rootDir}/lint.xml")
  44. htmlReport true
  45. htmlOutput file("$project.buildDir/reports/lint/lint.html")
  46. }
  47. dexOptions {
  48. javaMaxHeapSize "4g"
  49. }
  50. compileSdkVersion 25
  51. buildToolsVersion "25.0.2"
  52. defaultConfig {
  53. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  54. // arguments to be passed to functional tests
  55. testInstrumentationRunnerArgument "TEST_USER", "\"$System.env.OCTEST_APP_USERNAME\""
  56. testInstrumentationRunnerArgument "TEST_PASSWORD", "\"$System.env.OCTEST_APP_PASSWORD\""
  57. testInstrumentationRunnerArgument "TEST_SERVER_URL", "\"$System.env.OCTEST_SERVER_BASE_URL\""
  58. multiDexEnabled true
  59. // adapt structure from Eclipse to Gradle/Android Studio expectations;
  60. // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
  61. productFlavors {
  62. generic {
  63. applicationId 'com.nextcloud.client'
  64. }
  65. custom {
  66. // structure is:
  67. // domain tld
  68. // domain name
  69. // .client
  70. applicationId 'com.custom.client'
  71. }
  72. }
  73. configurations {
  74. customCompile
  75. }
  76. }
  77. // adapt structure from Eclipse to Gradle/Android Studio expectations;
  78. // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
  79. dexOptions {
  80. // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
  81. preDexLibraries = preDexEnabled && !travisBuild
  82. }
  83. compileOptions {
  84. sourceCompatibility JavaVersion.VERSION_1_7
  85. targetCompatibility JavaVersion.VERSION_1_7
  86. }
  87. lintOptions {
  88. abortOnError false
  89. }
  90. packagingOptions {
  91. exclude 'META-INF/LICENSE.txt'
  92. }
  93. task checkstyle(type: Checkstyle) {
  94. configFile = file("${rootProject.projectDir}/checkstyle.xml")
  95. configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
  96. source 'src'
  97. include '**/*.java'
  98. exclude '**/gen/**'
  99. classpath = files()
  100. }
  101. task pmd(type: Pmd) {
  102. ruleSetFiles = files("${project.rootDir}/pmd-ruleset.xml")
  103. ignoreFailures = false
  104. ruleSets = []
  105. source 'src'
  106. include '**/*.java'
  107. exclude '**/gen/**'
  108. reports {
  109. xml.enabled = false
  110. html.enabled = true
  111. xml {
  112. destination "$project.buildDir/reports/pmd/pmd.xml"
  113. }
  114. html {
  115. destination "$project.buildDir/reports/pmd/pmd.html"
  116. }
  117. }
  118. }
  119. task findbugs(type: FindBugs) {
  120. ignoreFailures = false
  121. effort = "max"
  122. reportLevel = "high"
  123. classes = files("$project.buildDir/intermediates/classes")
  124. excludeFilter = new File("${project.rootDir}/findbugs-filter.xml")
  125. source 'src'
  126. include '**/*.java'
  127. exclude '**/gen/**'
  128. reports {
  129. xml.enabled = false
  130. html.enabled = true
  131. html {
  132. destination "$project.buildDir/reports/findbugs/findbugs.html"
  133. }
  134. }
  135. classpath = files()
  136. }
  137. check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
  138. }
  139. dependencies {
  140. /// dependencies for app building
  141. compile name: 'touch-image-view'
  142. compile 'com.android.support:multidex:1.0.1'
  143. compile 'com.github.nextcloud:android-library:search-SNAPSHOT'
  144. compile "com.android.support:support-v4:${supportLibraryVersion}"
  145. compile "com.android.support:design:${supportLibraryVersion}"
  146. compile 'com.jakewharton:disklrucache:2.0.2'
  147. compile "com.android.support:appcompat-v7:${supportLibraryVersion}"
  148. compile 'com.getbase:floatingactionbutton:1.10.1'
  149. compile 'com.google.code.findbugs:annotations:2.0.1'
  150. compile group: 'commons-io', name: 'commons-io', version: '2.4'
  151. compile 'com.google.android.gms:play-services:10.2.0'
  152. compile 'com.github.evernote:android-job:v1.1.7'
  153. compile 'org.greenrobot:eventbus:3.0.0'
  154. compile 'org.parceler:parceler-api:1.1.6'
  155. annotationProcessor 'org.parceler:parceler:1.1.6'
  156. customCompile 'com.google.firebase:firebase-core:10.2.0'
  157. /// dependencies for local unit tests
  158. testCompile 'junit:junit:4.12'
  159. testCompile 'org.mockito:mockito-core:1.10.19'
  160. /// dependencies for instrumented tests
  161. // JUnit4 Rules
  162. androidTestCompile 'com.android.support.test:rules:0.5'
  163. // Android JUnit Runner
  164. androidTestCompile 'com.android.support.test:runner:0.5'
  165. // Android Annotation Support
  166. androidTestCompile "com.android.support:support-annotations:25.2.0"
  167. // Espresso core
  168. androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
  169. // UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
  170. //androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
  171. // fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
  172. //androidTestCompile "com.android.support:support-annotations:${supportLibraryVersion}"
  173. }
  174. tasks.withType(Test) {
  175. /// increased logging for tests
  176. testLogging {
  177. events "passed", "skipped", "failed"
  178. }
  179. }
  180. apply plugin: 'com.google.gms.google-services'