build.gradle 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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.0'
  13. }
  14. }
  15. apply plugin: 'com.android.application'
  16. apply plugin: 'checkstyle'
  17. apply plugin: 'pmd'
  18. apply plugin: 'findbugs'
  19. ext {
  20. supportLibraryVersion = '23.4.0'
  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.android.support:cardview-v7:${supportLibraryVersion}"
  38. compile 'com.getbase:floatingactionbutton:1.10.1'
  39. /// dependencies for local unit tests
  40. testCompile 'junit:junit:4.12'
  41. testCompile 'org.mockito:mockito-core:1.10.19'
  42. /// dependencies for instrumented tests
  43. // JUnit4 Rules
  44. androidTestCompile 'com.android.support.test:rules:0.5'
  45. // Android JUnit Runner
  46. androidTestCompile 'com.android.support.test:runner:0.5'
  47. // Android Annotation Support
  48. androidTestCompile "com.android.support:support-annotations:${supportLibraryVersion}"
  49. // Espresso core
  50. androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
  51. // UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
  52. androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
  53. }
  54. tasks.withType(Test) {
  55. /// increased logging for tests
  56. testLogging {
  57. events "passed", "skipped", "failed"
  58. }
  59. }
  60. android {
  61. lintOptions {
  62. abortOnError true
  63. lintConfig file("${project.rootDir}/lint.xml")
  64. htmlReport true
  65. htmlOutput file("$project.buildDir/reports/lint/lint.html")
  66. }
  67. compileSdkVersion 23
  68. buildToolsVersion "23.0.3"
  69. defaultConfig {
  70. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  71. // arguments to be passed to functional tests
  72. testInstrumentationRunnerArgument "TEST_USER", "\"$System.env.OCTEST_APP_USERNAME\""
  73. testInstrumentationRunnerArgument "TEST_PASSWORD", "\"$System.env.OCTEST_APP_PASSWORD\""
  74. testInstrumentationRunnerArgument "TEST_SERVER_URL", "\"$System.env.OCTEST_SERVER_BASE_URL\""
  75. applicationId "com.nextcloud.client"
  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. sourceSets {
  80. main {
  81. manifest.srcFile 'AndroidManifest.xml'
  82. java.srcDirs = ['src']
  83. resources.srcDirs = ['src']
  84. aidl.srcDirs = ['src']
  85. renderscript.srcDirs = ['src']
  86. res.srcDirs = ['res']
  87. assets.srcDirs = ['assets']
  88. }
  89. // move whole local unit tests structure as a whole from src/test/* to test/*
  90. test.setRoot('test')
  91. // move whole instrumented tests structure as a whole from src/androidTest/* to androidTest/*
  92. androidTest.setRoot('androidTest')
  93. // Move the build types to build-types/<type>
  94. // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
  95. // This moves them out of them default location under src/<type>/... which would
  96. // conflict with src/ being used by the main source set.
  97. // Adding new build types or product flavors should be accompanied
  98. // by a similar customization.
  99. debug.setRoot('build-types/debug')
  100. release.setRoot('build-types/release')
  101. }
  102. compileOptions {
  103. sourceCompatibility JavaVersion.VERSION_1_7
  104. targetCompatibility JavaVersion.VERSION_1_7
  105. }
  106. lintOptions {
  107. abortOnError false
  108. }
  109. packagingOptions {
  110. exclude 'META-INF/LICENSE.txt'
  111. }
  112. task checkstyle(type: Checkstyle) {
  113. configFile = file("${rootProject.projectDir}/checkstyle.xml")
  114. configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
  115. source 'src'
  116. include '**/*.java'
  117. exclude '**/gen/**'
  118. classpath = files()
  119. }
  120. task pmd(type: Pmd) {
  121. ruleSetFiles = files("${project.rootDir}/pmd-ruleset.xml")
  122. ignoreFailures = false
  123. ruleSets = []
  124. source 'src'
  125. include '**/*.java'
  126. exclude '**/gen/**'
  127. reports {
  128. xml.enabled = false
  129. html.enabled = true
  130. xml {
  131. destination "$project.buildDir/reports/pmd/pmd.xml"
  132. }
  133. html {
  134. destination "$project.buildDir/reports/pmd/pmd.html"
  135. }
  136. }
  137. }
  138. task findbugs(type: FindBugs) {
  139. ignoreFailures = false
  140. effort = "max"
  141. reportLevel = "high"
  142. classes = files("$project.buildDir/intermediates/classes")
  143. excludeFilter = new File("${project.rootDir}/findbugs-filter.xml")
  144. source 'src'
  145. include '**/*.java'
  146. exclude '**/gen/**'
  147. reports {
  148. xml.enabled = false
  149. html.enabled = true
  150. html {
  151. destination "$project.buildDir/reports/findbugs/findbugs.html"
  152. }
  153. }
  154. classpath = files()
  155. }
  156. check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
  157. }