build.gradle 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. }
  11. dependencies {
  12. classpath 'com.android.tools.build:gradle:2.2.1'
  13. }
  14. }
  15. apply plugin: 'com.android.application'
  16. apply plugin: 'checkstyle'
  17. apply plugin: 'pmd'
  18. apply plugin: 'findbugs'
  19. ext {
  20. supportLibraryVersion = '24.1.1'
  21. }
  22. repositories {
  23. jcenter()
  24. maven { url "https://jitpack.io" }
  25. flatDir {
  26. dirs 'libs'
  27. }
  28. }
  29. dependencies {
  30. /// dependencies for app building
  31. compile name: 'touch-image-view'
  32. compile 'com.github.nextcloud:android-library:1.0.7'
  33. compile "com.android.support:support-v4:${supportLibraryVersion}"
  34. compile "com.android.support:design:${supportLibraryVersion}"
  35. compile 'com.jakewharton:disklrucache:2.0.2'
  36. compile "com.android.support:appcompat-v7:${supportLibraryVersion}"
  37. compile 'com.getbase:floatingactionbutton:1.10.1'
  38. /// dependencies for local unit tests
  39. testCompile 'junit:junit:4.12'
  40. testCompile 'org.mockito:mockito-core:1.10.19'
  41. /// dependencies for instrumented tests
  42. // JUnit4 Rules
  43. androidTestCompile 'com.android.support.test:rules:0.5'
  44. // Android JUnit Runner
  45. androidTestCompile 'com.android.support.test:runner:0.5'
  46. // Android Annotation Support
  47. androidTestCompile "com.android.support:support-annotations:${supportLibraryVersion}"
  48. // Espresso core
  49. androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
  50. // UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
  51. androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
  52. // fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
  53. androidTestCompile "com.android.support:support-annotations:${supportLibraryVersion}"
  54. }
  55. tasks.withType(Test) {
  56. /// increased logging for tests
  57. testLogging {
  58. events "passed", "skipped", "failed"
  59. }
  60. }
  61. android {
  62. lintOptions {
  63. abortOnError true
  64. lintConfig file("${project.rootDir}/lint.xml")
  65. htmlReport true
  66. htmlOutput file("$project.buildDir/reports/lint/lint.html")
  67. }
  68. compileSdkVersion 24
  69. buildToolsVersion "24.0.0"
  70. defaultConfig {
  71. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  72. // arguments to be passed to functional tests
  73. testInstrumentationRunnerArgument "TEST_USER", "\"$System.env.OCTEST_APP_USERNAME\""
  74. testInstrumentationRunnerArgument "TEST_PASSWORD", "\"$System.env.OCTEST_APP_PASSWORD\""
  75. testInstrumentationRunnerArgument "TEST_SERVER_URL", "\"$System.env.OCTEST_SERVER_BASE_URL\""
  76. applicationId "com.nextcloud.client"
  77. // Enable the experimental Jack build tools.
  78. jackOptions {
  79. enabled true
  80. }
  81. }
  82. // adapt structure from Eclipse to Gradle/Android Studio expectations;
  83. // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
  84. sourceSets {
  85. main {
  86. manifest.srcFile 'AndroidManifest.xml'
  87. java.srcDirs = ['src']
  88. resources.srcDirs = ['src']
  89. aidl.srcDirs = ['src']
  90. renderscript.srcDirs = ['src']
  91. res.srcDirs = ['res']
  92. assets.srcDirs = ['assets']
  93. }
  94. // move whole local unit tests structure as a whole from src/test/* to test/*
  95. test.setRoot('test')
  96. // move whole instrumented tests structure as a whole from src/androidTest/* to androidTest/*
  97. androidTest.setRoot('androidTest')
  98. // Move the build types to build-types/<type>
  99. // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
  100. // This moves them out of them default location under src/<type>/... which would
  101. // conflict with src/ being used by the main source set.
  102. // Adding new build types or product flavors should be accompanied
  103. // by a similar customization.
  104. debug.setRoot('build-types/debug')
  105. release.setRoot('build-types/release')
  106. }
  107. compileOptions {
  108. sourceCompatibility JavaVersion.VERSION_1_8
  109. targetCompatibility JavaVersion.VERSION_1_8
  110. }
  111. lintOptions {
  112. abortOnError false
  113. }
  114. packagingOptions {
  115. exclude 'META-INF/LICENSE.txt'
  116. }
  117. task checkstyle(type: Checkstyle) {
  118. configFile = file("${rootProject.projectDir}/checkstyle.xml")
  119. configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
  120. source 'src'
  121. include '**/*.java'
  122. exclude '**/gen/**'
  123. classpath = files()
  124. }
  125. task pmd(type: Pmd) {
  126. ruleSetFiles = files("${project.rootDir}/pmd-ruleset.xml")
  127. ignoreFailures = false
  128. ruleSets = []
  129. source 'src'
  130. include '**/*.java'
  131. exclude '**/gen/**'
  132. reports {
  133. xml.enabled = false
  134. html.enabled = true
  135. xml {
  136. destination "$project.buildDir/reports/pmd/pmd.xml"
  137. }
  138. html {
  139. destination "$project.buildDir/reports/pmd/pmd.html"
  140. }
  141. }
  142. }
  143. task findbugs(type: FindBugs) {
  144. ignoreFailures = false
  145. effort = "max"
  146. reportLevel = "high"
  147. classes = files("$project.buildDir/intermediates/classes")
  148. excludeFilter = new File("${project.rootDir}/findbugs-filter.xml")
  149. source 'src'
  150. include '**/*.java'
  151. exclude '**/gen/**'
  152. reports {
  153. xml.enabled = false
  154. html.enabled = true
  155. html {
  156. destination "$project.buildDir/reports/findbugs/findbugs.html"
  157. }
  158. }
  159. classpath = files()
  160. }
  161. check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
  162. }