build.gradle 11 KB

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