build.gradle 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. mavenCentral()
  15. }
  16. dependencies {
  17. classpath 'com.android.tools.build:gradle:3.1.4'
  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. jacocoVersion = "0.7.4.201502262128"
  36. travisBuild = System.getenv("TRAVIS") == "true"
  37. // allows for -Dpre-dex=false to be set
  38. preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
  39. }
  40. repositories {
  41. jcenter()
  42. maven { url "https://jitpack.io" }
  43. maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
  44. google()
  45. flatDir {
  46. dirs 'libs'
  47. }
  48. }
  49. // semantic versioning for version code
  50. def versionMajor = 3
  51. def versionMinor = 3
  52. def versionPatch = 0
  53. def versionBuild = 0 // 0-49=Alpha / 50-98=RC / 99=stable
  54. def taskRequest = getGradle().getStartParameter().getTaskRequests().toString()
  55. if (taskRequest.contains("Gplay") || taskRequest.contains("findbugs") || taskRequest.contains("lint")) {
  56. apply from: 'gplay.gradle'
  57. }
  58. android {
  59. lintOptions {
  60. abortOnError false
  61. htmlReport true
  62. htmlOutput file("$project.buildDir/reports/lint/lint.html")
  63. disable 'MissingTranslation'
  64. }
  65. dexOptions {
  66. javaMaxHeapSize "4g"
  67. }
  68. compileSdkVersion 27
  69. defaultConfig {
  70. minSdkVersion 14
  71. targetSdkVersion 27
  72. testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  73. // arguments to be passed to functional tests
  74. testInstrumentationRunnerArgument "TEST_USER", "\"$System.env.OCTEST_APP_USERNAME\""
  75. testInstrumentationRunnerArgument "TEST_PASSWORD", "\"$System.env.OCTEST_APP_PASSWORD\""
  76. testInstrumentationRunnerArgument "TEST_SERVER_URL", "\"$System.env.OCTEST_SERVER_BASE_URL\""
  77. multiDexEnabled true
  78. versionCode versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
  79. if (versionBuild > 98) {
  80. versionName "${versionMajor}.${versionMinor}.${versionPatch}"
  81. } else if (versionBuild > 49) {
  82. versionName "${versionMajor}.${versionMinor}.${versionPatch} RC"+(versionBuild-49)
  83. } else {
  84. versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha"+(versionBuild+1)
  85. }
  86. // adapt structure from Eclipse to Gradle/Android Studio expectations;
  87. // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
  88. flavorDimensions "default"
  89. buildTypes {
  90. debug {
  91. testCoverageEnabled true
  92. }
  93. }
  94. productFlavors {
  95. // used for f-droid
  96. generic {
  97. applicationId 'com.nextcloud.client'
  98. dimension "default"
  99. }
  100. gplay {
  101. applicationId 'com.nextcloud.client'
  102. dimension "default"
  103. }
  104. versionDev {
  105. applicationId "com.nextcloud.android.beta"
  106. dimension "default"
  107. versionCode 20180829
  108. versionName "20180829"
  109. }
  110. }
  111. }
  112. // adapt structure from Eclipse to Gradle/Android Studio expectations;
  113. // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
  114. dexOptions {
  115. // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
  116. preDexLibraries = preDexEnabled && !travisBuild
  117. }
  118. packagingOptions {
  119. exclude 'META-INF/LICENSE.txt'
  120. exclude 'META-INF/LICENSE'
  121. }
  122. task checkstyle(type: Checkstyle) {
  123. configFile = file("${rootProject.projectDir}/checkstyle.xml")
  124. configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
  125. source 'src'
  126. include '**/*.java'
  127. exclude '**/gen/**'
  128. classpath = files()
  129. }
  130. task pmd(type: Pmd) {
  131. ruleSetFiles = files("${project.rootDir}/pmd-ruleset.xml")
  132. ignoreFailures = false
  133. ruleSets = []
  134. source 'src'
  135. include '**/*.java'
  136. exclude '**/gen/**'
  137. reports {
  138. xml.enabled = false
  139. html.enabled = true
  140. xml {
  141. destination = file("$project.buildDir/reports/pmd/pmd.xml")
  142. }
  143. html {
  144. destination = file("$project.buildDir/reports/pmd/pmd.html")
  145. }
  146. }
  147. }
  148. task findbugs(type: FindBugs) {
  149. ignoreFailures = false
  150. effort = "max"
  151. reportLevel = "medium"
  152. classes = fileTree("$project.buildDir/intermediates/classes/gplay/debug/com/owncloud")
  153. excludeFilter = file("${project.rootDir}/findbugs-filter.xml")
  154. source = fileTree('src/main/java')
  155. pluginClasspath = project.configurations.findbugsPlugins
  156. classpath = files()
  157. include '**/*.java'
  158. exclude '**/gen/**'
  159. reports {
  160. xml.enabled = false
  161. html.enabled = true
  162. html {
  163. destination = file("$project.buildDir/reports/findbugs/findbugs.html")
  164. }
  165. }
  166. }
  167. check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
  168. compileOptions {
  169. sourceCompatibility JavaVersion.VERSION_1_8
  170. targetCompatibility JavaVersion.VERSION_1_8
  171. }
  172. }
  173. dependencies {
  174. // dependencies for app building
  175. implementation 'com.android.support:multidex:1.0.3'
  176. // implementation project('nextcloud-android-library')
  177. genericImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
  178. gplayImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
  179. versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' // use always latest master
  180. implementation "com.android.support:support-v4:${supportLibraryVersion}"
  181. implementation "com.android.support:design:${supportLibraryVersion}"
  182. implementation 'com.jakewharton:disklrucache:2.0.2'
  183. implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
  184. implementation "com.android.support:cardview-v7:${supportLibraryVersion}"
  185. implementation "com.android.support:exifinterface:${supportLibraryVersion}"
  186. implementation 'com.github.albfernandez:juniversalchardet:v2.0.0'
  187. implementation 'com.google.code.findbugs:annotations:2.0.1'
  188. implementation 'commons-io:commons-io:2.5'
  189. implementation 'com.github.evernote:android-job:v1.2.5'
  190. implementation 'com.jakewharton:butterknife:8.8.1'
  191. annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
  192. implementation 'org.greenrobot:eventbus:3.0.0'
  193. implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.4'
  194. implementation 'org.lukhnos:nnio:0.2'
  195. implementation 'com.madgag.spongycastle:pkix:1.54.0.0'
  196. implementation 'com.google.code.gson:gson:2.8.2'
  197. implementation 'com.afollestad:sectioned-recyclerview:0.5.0'
  198. implementation 'com.github.chrisbanes:PhotoView:2.1.3'
  199. implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15'
  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.3'
  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:2.2.5'
  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. findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.4.4'
  226. findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.2'
  227. // jacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
  228. // jacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  229. // androidJacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  230. // androidJacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
  231. // androidJacocoAnt "org.jacoco:org.jacoco.core:${jacocoVersion}"
  232. // androidJacocoAnt "org.jacoco:org.jacoco.report:${jacocoVersion}"
  233. // androidJacocoAnt "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  234. }
  235. configurations.all {
  236. resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
  237. }
  238. tasks.withType(Test) {
  239. // increased logging for tests
  240. testLogging {
  241. events "passed", "skipped", "failed"
  242. }
  243. }
  244. android.applicationVariants.all { variant ->
  245. variant.outputs.all { output ->
  246. outputFileName = "${output.baseName}-${variant.versionCode}.apk"
  247. }
  248. }
  249. task combinedTestReport(type: JacocoReport) {
  250. reports {
  251. xml.enabled = true
  252. html.enabled = true
  253. }
  254. def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
  255. def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/gplay/debug", excludes: fileFilter)
  256. def mainSrc = "$project.projectDir/src/main/java"
  257. sourceDirectories = files([mainSrc])
  258. classDirectories = files([debugTree])
  259. executionData = fileTree(dir: project.buildDir, includes: [
  260. 'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
  261. ])
  262. }