build.gradle 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. 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.4'
  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. /// dependencies for local unit tests
  42. testCompile 'junit:junit:4.12'
  43. testCompile 'org.mockito:mockito-core:1.10.19'
  44. /// dependencies for instrumented tests
  45. // JUnit4 Rules
  46. androidTestCompile 'com.android.support.test:rules:0.5'
  47. // Android JUnit Runner
  48. androidTestCompile 'com.android.support.test:runner:0.5'
  49. // Android Annotation Support
  50. androidTestCompile "com.android.support:support-annotations:${supportLibraryVersion}"
  51. // Espresso core
  52. androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
  53. // UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
  54. androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
  55. // fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
  56. androidTestCompile "com.android.support:support-annotations:${supportLibraryVersion}"
  57. }
  58. tasks.withType(Test) {
  59. /// increased logging for tests
  60. testLogging {
  61. events "passed", "skipped", "failed"
  62. }
  63. }
  64. android {
  65. lintOptions {
  66. abortOnError true
  67. lintConfig file("${project.rootDir}/lint.xml")
  68. htmlReport true
  69. htmlOutput file("$project.buildDir/reports/lint/lint.html")
  70. }
  71. compileSdkVersion 24
  72. buildToolsVersion "24.0.2"
  73. defaultConfig {
  74. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  75. // arguments to be passed to functional tests
  76. testInstrumentationRunnerArgument "TEST_USER", "\"$System.env.OCTEST_APP_USERNAME\""
  77. testInstrumentationRunnerArgument "TEST_PASSWORD", "\"$System.env.OCTEST_APP_PASSWORD\""
  78. testInstrumentationRunnerArgument "TEST_SERVER_URL", "\"$System.env.OCTEST_SERVER_BASE_URL\""
  79. applicationId "com.nextcloud.client"
  80. }
  81. // adapt structure from Eclipse to Gradle/Android Studio expectations;
  82. // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
  83. sourceSets {
  84. main {
  85. manifest.srcFile 'AndroidManifest.xml'
  86. java.srcDirs = ['src']
  87. resources.srcDirs = ['src']
  88. aidl.srcDirs = ['src']
  89. renderscript.srcDirs = ['src']
  90. res.srcDirs = ['res']
  91. assets.srcDirs = ['assets']
  92. }
  93. // move whole local unit tests structure as a whole from src/test/* to test/*
  94. test.setRoot('test')
  95. // move whole instrumented tests structure as a whole from src/androidTest/* to androidTest/*
  96. androidTest.setRoot('androidTest')
  97. // Move the build types to build-types/<type>
  98. // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
  99. // This moves them out of them default location under src/<type>/... which would
  100. // conflict with src/ being used by the main source set.
  101. // Adding new build types or product flavors should be accompanied
  102. // by a similar customization.
  103. debug.setRoot('build-types/debug')
  104. release.setRoot('build-types/release')
  105. }
  106. dexOptions {
  107. // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
  108. preDexLibraries = preDexEnabled && !travisBuild
  109. }
  110. compileOptions {
  111. sourceCompatibility JavaVersion.VERSION_1_7
  112. targetCompatibility JavaVersion.VERSION_1_7
  113. }
  114. lintOptions {
  115. abortOnError false
  116. }
  117. packagingOptions {
  118. exclude 'META-INF/LICENSE.txt'
  119. }
  120. task checkstyle(type: Checkstyle) {
  121. configFile = file("${rootProject.projectDir}/checkstyle.xml")
  122. configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
  123. source 'src'
  124. include '**/*.java'
  125. exclude '**/gen/**'
  126. classpath = files()
  127. }
  128. task pmd(type: Pmd) {
  129. ruleSetFiles = files("${project.rootDir}/pmd-ruleset.xml")
  130. ignoreFailures = false
  131. ruleSets = []
  132. source 'src'
  133. include '**/*.java'
  134. exclude '**/gen/**'
  135. reports {
  136. xml.enabled = false
  137. html.enabled = true
  138. xml {
  139. destination "$project.buildDir/reports/pmd/pmd.xml"
  140. }
  141. html {
  142. destination "$project.buildDir/reports/pmd/pmd.html"
  143. }
  144. }
  145. }
  146. task findbugs(type: FindBugs) {
  147. ignoreFailures = false
  148. effort = "max"
  149. reportLevel = "high"
  150. classes = files("$project.buildDir/intermediates/classes")
  151. excludeFilter = new File("${project.rootDir}/findbugs-filter.xml")
  152. source 'src'
  153. include '**/*.java'
  154. exclude '**/gen/**'
  155. reports {
  156. xml.enabled = false
  157. html.enabled = true
  158. html {
  159. destination "$project.buildDir/reports/findbugs/findbugs.html"
  160. }
  161. }
  162. classpath = files()
  163. }
  164. check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
  165. }