build.gradle 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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.2.1'
  21. travisBuild = System.getenv("TRAVIS") == "true"
  22. // allows for -Dpre-dex=false to be set
  23. preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
  24. }
  25. repositories {
  26. jcenter()
  27. maven { url "https://jitpack.io" }
  28. flatDir {
  29. dirs 'libs'
  30. }
  31. }
  32. dependencies {
  33. /// dependencies for app building
  34. compile name: 'touch-image-view'
  35. compile 'com.github.nextcloud:android-library:1.0.9'
  36. compile "com.android.support:support-v4:${supportLibraryVersion}"
  37. compile "com.android.support:design:${supportLibraryVersion}"
  38. compile 'com.jakewharton:disklrucache:2.0.2'
  39. compile "com.android.support:appcompat-v7:${supportLibraryVersion}"
  40. compile 'com.getbase:floatingactionbutton:1.10.1'
  41. compile 'com.google.code.findbugs:annotations:2.0.1'
  42. /// dependencies for local unit tests
  43. testCompile 'junit:junit:4.12'
  44. testCompile 'org.mockito:mockito-core:1.10.19'
  45. /// dependencies for instrumented tests
  46. // JUnit4 Rules
  47. androidTestCompile 'com.android.support.test:rules:0.5'
  48. // Android JUnit Runner
  49. androidTestCompile 'com.android.support.test:runner:0.5'
  50. // Android Annotation Support
  51. androidTestCompile "com.android.support:support-annotations:${supportLibraryVersion}"
  52. // Espresso core
  53. androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
  54. // UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
  55. androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
  56. // fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
  57. androidTestCompile "com.android.support:support-annotations:${supportLibraryVersion}"
  58. }
  59. tasks.withType(Test) {
  60. /// increased logging for tests
  61. testLogging {
  62. events "passed", "skipped", "failed"
  63. }
  64. }
  65. android {
  66. lintOptions {
  67. abortOnError true
  68. lintConfig file("${project.rootDir}/lint.xml")
  69. htmlReport true
  70. htmlOutput file("$project.buildDir/reports/lint/lint.html")
  71. }
  72. compileSdkVersion 24
  73. buildToolsVersion "24.0.2"
  74. defaultConfig {
  75. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  76. // arguments to be passed to functional tests
  77. testInstrumentationRunnerArgument "TEST_USER", "\"$System.env.OCTEST_APP_USERNAME\""
  78. testInstrumentationRunnerArgument "TEST_PASSWORD", "\"$System.env.OCTEST_APP_PASSWORD\""
  79. testInstrumentationRunnerArgument "TEST_SERVER_URL", "\"$System.env.OCTEST_SERVER_BASE_URL\""
  80. applicationId "com.nextcloud.client"
  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. dexOptions {
  108. // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
  109. preDexLibraries = preDexEnabled && !travisBuild
  110. }
  111. compileOptions {
  112. sourceCompatibility JavaVersion.VERSION_1_7
  113. targetCompatibility JavaVersion.VERSION_1_7
  114. }
  115. lintOptions {
  116. abortOnError false
  117. }
  118. packagingOptions {
  119. exclude 'META-INF/LICENSE.txt'
  120. }
  121. task checkstyle(type: Checkstyle) {
  122. configFile = file("${rootProject.projectDir}/checkstyle.xml")
  123. configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
  124. source 'src'
  125. include '**/*.java'
  126. exclude '**/gen/**'
  127. classpath = files()
  128. }
  129. task pmd(type: Pmd) {
  130. ruleSetFiles = files("${project.rootDir}/pmd-ruleset.xml")
  131. ignoreFailures = false
  132. ruleSets = []
  133. source 'src'
  134. include '**/*.java'
  135. exclude '**/gen/**'
  136. reports {
  137. xml.enabled = false
  138. html.enabled = true
  139. xml {
  140. destination "$project.buildDir/reports/pmd/pmd.xml"
  141. }
  142. html {
  143. destination "$project.buildDir/reports/pmd/pmd.html"
  144. }
  145. }
  146. }
  147. task findbugs(type: FindBugs) {
  148. ignoreFailures = false
  149. effort = "max"
  150. reportLevel = "high"
  151. classes = files("$project.buildDir/intermediates/classes")
  152. excludeFilter = new File("${project.rootDir}/findbugs-filter.xml")
  153. source 'src'
  154. include '**/*.java'
  155. exclude '**/gen/**'
  156. reports {
  157. xml.enabled = false
  158. html.enabled = true
  159. html {
  160. destination "$project.buildDir/reports/findbugs/findbugs.html"
  161. }
  162. }
  163. classpath = files()
  164. }
  165. check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
  166. }