build.gradle 7.4 KB

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