build.gradle 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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. google()
  14. }
  15. dependencies {
  16. classpath 'com.android.tools.build:gradle:3.1.3'
  17. classpath 'com.google.gms:google-services:3.0.0'
  18. classpath 'org.codehaus.groovy:groovy-all:2.4.12'
  19. classpath('com.dicedmelon.gradle:jacoco-android:0.1.2') {
  20. exclude group: 'org.codehaus.groovy', module: 'groovy-all'
  21. }
  22. }
  23. }
  24. apply plugin: 'com.android.application'
  25. apply plugin: 'checkstyle'
  26. apply plugin: 'pmd'
  27. apply plugin: 'findbugs'
  28. apply plugin: 'jacoco-android'
  29. configurations.all {
  30. // check for updates every build
  31. resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
  32. }
  33. ext {
  34. supportLibraryVersion = '27.1.1'
  35. googleLibraryVersion = '12.0.1'
  36. androidLibraryVersion = '1.0.40'
  37. jacocoVersion = "0.7.4.201502262128"
  38. travisBuild = System.getenv("TRAVIS") == "true"
  39. // allows for -Dpre-dex=false to be set
  40. preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
  41. }
  42. repositories {
  43. jcenter()
  44. maven { url "https://jitpack.io" }
  45. maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
  46. google()
  47. flatDir {
  48. dirs 'libs'
  49. }
  50. }
  51. // semantic versioning for version code
  52. def versionMajor = 3
  53. def versionMinor = 3
  54. def versionPatch = 0
  55. def versionBuild = 0 // 0-49=Alpha / 50-98=RC / 99=stable
  56. android {
  57. lintOptions {
  58. abortOnError false
  59. htmlReport true
  60. htmlOutput file("$project.buildDir/reports/lint/lint.html")
  61. disable 'MissingTranslation'
  62. }
  63. dexOptions {
  64. javaMaxHeapSize "4g"
  65. }
  66. compileSdkVersion 27
  67. defaultConfig {
  68. minSdkVersion 14
  69. targetSdkVersion 27
  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. multiDexEnabled true
  76. versionCode versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
  77. if (versionBuild > 98) {
  78. versionName "${versionMajor}.${versionMinor}.${versionPatch}"
  79. } else if (versionBuild > 49) {
  80. versionName "${versionMajor}.${versionMinor}.${versionPatch} RC"+(versionBuild-49)
  81. } else {
  82. versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha"+(versionBuild+1)
  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. flavorDimensions "default"
  87. buildTypes {
  88. debug {
  89. testCoverageEnabled true
  90. }
  91. }
  92. productFlavors {
  93. // used for f-droid
  94. generic {
  95. applicationId 'com.nextcloud.client'
  96. dimension "default"
  97. }
  98. gplay {
  99. applicationId 'com.nextcloud.client'
  100. dimension "default"
  101. }
  102. versionDev {
  103. applicationId "com.nextcloud.android.beta"
  104. dimension "default"
  105. versionCode 20180619
  106. versionName "20180619"
  107. }
  108. }
  109. }
  110. // adapt structure from Eclipse to Gradle/Android Studio expectations;
  111. // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
  112. dexOptions {
  113. // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
  114. preDexLibraries = preDexEnabled && !travisBuild
  115. }
  116. packagingOptions {
  117. exclude 'META-INF/LICENSE.txt'
  118. exclude 'META-INF/LICENSE'
  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 = file("$project.buildDir/reports/pmd/pmd.xml")
  140. }
  141. html {
  142. destination = file("$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 = file("$project.buildDir/reports/findbugs/findbugs.html")
  160. }
  161. }
  162. classpath = files()
  163. }
  164. check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
  165. compileOptions {
  166. sourceCompatibility JavaVersion.VERSION_1_8
  167. targetCompatibility JavaVersion.VERSION_1_8
  168. }
  169. }
  170. dependencies {
  171. // dependencies for app building
  172. implementation 'com.android.support:multidex:1.0.3'
  173. // implementation project('nextcloud-android-library')
  174. genericImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
  175. gplayImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
  176. versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' // use always latest master
  177. implementation "com.android.support:support-v4:${supportLibraryVersion}"
  178. implementation "com.android.support:design:${supportLibraryVersion}"
  179. implementation 'com.jakewharton:disklrucache:2.0.2'
  180. implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
  181. implementation "com.android.support:cardview-v7:${supportLibraryVersion}"
  182. implementation "com.android.support:exifinterface:${supportLibraryVersion}"
  183. implementation 'com.github.albfernandez:juniversalchardet:v2.0.0'
  184. implementation 'com.google.code.findbugs:annotations:2.0.1'
  185. implementation 'commons-io:commons-io:2.5'
  186. implementation 'com.github.evernote:android-job:v1.2.5'
  187. implementation 'com.jakewharton:butterknife:8.8.1'
  188. annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
  189. implementation 'org.greenrobot:eventbus:3.0.0'
  190. implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.2'
  191. implementation 'org.lukhnos:nnio:0.2'
  192. implementation 'com.madgag.spongycastle:pkix:1.54.0.0'
  193. implementation 'com.google.code.gson:gson:2.8.2'
  194. implementation 'com.afollestad:sectioned-recyclerview:0.5.0'
  195. implementation 'com.github.chrisbanes:PhotoView:2.1.3'
  196. implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.12'
  197. // uncomment for gplay
  198. // implementation "com.google.firebase:firebase-messaging:${googleLibraryVersion}"
  199. // implementation "com.google.android.gms:play-services-gcm:${googleLibraryVersion}"
  200. implementation 'org.parceler:parceler-api:1.1.9'
  201. annotationProcessor 'org.parceler:parceler:1.1.9'
  202. implementation ('com.github.bumptech.glide:glide:3.7.0') {
  203. exclude group: "com.android.support"
  204. }
  205. implementation 'com.caverock:androidsvg:1.2.1'
  206. implementation "com.android.support:support-annotations:${supportLibraryVersion}"
  207. implementation 'com.google.code.gson:gson:2.8.2'
  208. // dependencies for local unit tests
  209. testImplementation 'junit:junit:4.12'
  210. testImplementation 'org.mockito:mockito-core:1.10.19'
  211. // dependencies for instrumented tests
  212. // JUnit4 Rules
  213. androidTestImplementation 'com.android.support.test:rules:1.0.2'
  214. // Android JUnit Runner
  215. androidTestImplementation 'com.android.support.test:runner:1.0.2'
  216. // Espresso core
  217. androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
  218. androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
  219. // UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
  220. androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
  221. // fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
  222. //androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
  223. implementation 'org.jetbrains:annotations:15.0'
  224. androidTestImplementation 'tools.fastlane:screengrab:1.0.0'
  225. // jacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
  226. // jacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  227. // androidJacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  228. // androidJacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
  229. // androidJacocoAnt "org.jacoco:org.jacoco.core:${jacocoVersion}"
  230. // androidJacocoAnt "org.jacoco:org.jacoco.report:${jacocoVersion}"
  231. // androidJacocoAnt "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  232. }
  233. configurations.all {
  234. resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
  235. }
  236. tasks.withType(Test) {
  237. // increased logging for tests
  238. testLogging {
  239. events "passed", "skipped", "failed"
  240. }
  241. }
  242. android.applicationVariants.all { variant ->
  243. variant.outputs.all { output ->
  244. outputFileName = "${output.baseName}-${variant.versionCode}.apk"
  245. }
  246. }
  247. task combinedTestReport(type: JacocoReport) {
  248. reports {
  249. xml.enabled = true
  250. html.enabled = true
  251. }
  252. def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
  253. def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/gplay/debug", excludes: fileFilter)
  254. def mainSrc = "$project.projectDir/src/main/java"
  255. sourceDirectories = files([mainSrc])
  256. classDirectories = files([debugTree])
  257. executionData = fileTree(dir: project.buildDir, includes: [
  258. 'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
  259. ])
  260. }
  261. // uncomment for gplay (must be at the bottom)
  262. // apply plugin: 'com.google.gms.google-services'