build.gradle 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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. google()
  10. jcenter()
  11. maven {
  12. url 'https://oss.sonatype.org/content/repositories/snapshots/'
  13. }
  14. mavenCentral()
  15. }
  16. dependencies {
  17. classpath 'com.android.tools.build:gradle:3.2.1'
  18. classpath('com.dicedmelon.gradle:jacoco-android:0.1.3')
  19. }
  20. }
  21. apply plugin: 'com.android.application'
  22. apply plugin: 'checkstyle'
  23. apply plugin: 'pmd'
  24. apply plugin: 'findbugs'
  25. apply plugin: 'jacoco-android'
  26. configurations.all {
  27. exclude group: 'com.google.firebase', module: 'firebase-core'
  28. // check for updates every build
  29. resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
  30. }
  31. ext {
  32. supportLibraryVersion = '28.0.0'
  33. jacocoVersion = "0.8.2"
  34. travisBuild = System.getenv("TRAVIS") == "true"
  35. // allows for -Dpre-dex=false to be set
  36. preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
  37. }
  38. repositories {
  39. google()
  40. jcenter()
  41. maven { url "https://jitpack.io" }
  42. maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
  43. flatDir {
  44. dirs 'libs'
  45. }
  46. }
  47. // semantic versioning for version code
  48. def versionMajor = 3
  49. def versionMinor = 4
  50. def versionPatch = 0
  51. def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 99=stable
  52. def taskRequest = getGradle().getStartParameter().getTaskRequests().toString()
  53. if (taskRequest.contains("Gplay") || taskRequest.contains("findbugs") || taskRequest.contains("lint")) {
  54. apply from: 'gplay.gradle'
  55. }
  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 28
  67. defaultConfig {
  68. minSdkVersion 14
  69. targetSdkVersion 28
  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 > 50) {
  80. versionName "${versionMajor}.${versionMinor}.${versionPatch} RC"+(versionBuild-50)
  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 20181106
  106. versionName "20181106"
  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 = "medium"
  150. classes = fileTree("$project.buildDir/intermediates/javac/gplayDebug/compileGplayDebugJavaWithJavac/classes/")
  151. excludeFilter = file("${project.rootDir}/findbugs-filter.xml")
  152. source = fileTree('src/main/java')
  153. pluginClasspath = project.configurations.findbugsPlugins
  154. classpath = files()
  155. include '**/*.java'
  156. exclude '**/gen/**'
  157. reports {
  158. xml.enabled = false
  159. html.enabled = true
  160. html {
  161. destination = file("$project.buildDir/reports/findbugs/findbugs.html")
  162. }
  163. }
  164. }
  165. check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
  166. compileOptions {
  167. sourceCompatibility JavaVersion.VERSION_1_8
  168. targetCompatibility JavaVersion.VERSION_1_8
  169. }
  170. }
  171. dependencies {
  172. // dependencies for app building
  173. implementation 'com.android.support:multidex:1.0.3'
  174. // implementation project('nextcloud-android-library')
  175. genericImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
  176. gplayImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
  177. versionDevImplementation "com.github.nextcloud:android-library:master-SNAPSHOT" // use always latest master
  178. implementation 'com.android.support.constraint:constraint-layout:1.1.3'
  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:2.0.0' // need this version for Android <7
  186. implementation 'com.google.code.findbugs:annotations:2.0.1'
  187. implementation 'commons-io:commons-io:2.6'
  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.1.1'
  192. implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.4'
  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.5'
  196. implementation 'com.afollestad:sectioned-recyclerview:0.5.0'
  197. implementation 'com.github.chrisbanes:PhotoView:2.1.4'
  198. implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15'
  199. implementation 'org.parceler:parceler-api:1.1.11'
  200. annotationProcessor 'org.parceler:parceler:1.1.11'
  201. implementation ('com.github.bumptech.glide:glide:3.7.0') {
  202. exclude group: "com.android.support"
  203. }
  204. implementation 'com.caverock:androidsvg:1.3'
  205. implementation "com.android.support:support-annotations:${supportLibraryVersion}"
  206. implementation 'com.google.code.gson:gson:2.8.5'
  207. // dependencies for local unit tests
  208. testImplementation 'junit:junit:4.12'
  209. testImplementation 'org.mockito:mockito-core:2.23.0'
  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:16.0.3'
  223. compileOnly "org.projectlombok:lombok:1.18.4"
  224. annotationProcessor "org.projectlombok:lombok:1.18.4"
  225. androidTestImplementation 'tools.fastlane:screengrab:1.2.0'
  226. findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.8.0'
  227. findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.3'
  228. // jacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
  229. // jacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  230. // androidJacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  231. // androidJacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
  232. // androidJacocoAnt "org.jacoco:org.jacoco.core:${jacocoVersion}"
  233. // androidJacocoAnt "org.jacoco:org.jacoco.report:${jacocoVersion}"
  234. // androidJacocoAnt "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  235. }
  236. configurations.all {
  237. resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
  238. }
  239. tasks.withType(Test) {
  240. // increased logging for tests
  241. testLogging {
  242. events "passed", "skipped", "failed"
  243. }
  244. }
  245. android.applicationVariants.all { variant ->
  246. variant.outputs.all { output ->
  247. outputFileName = "${output.baseName}-${variant.versionCode}.apk"
  248. }
  249. }
  250. task combinedTestReport(type: JacocoReport) {
  251. reports {
  252. xml.enabled = true
  253. html.enabled = true
  254. }
  255. def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
  256. def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/gplay/debug", excludes: fileFilter)
  257. def mainSrc = "$project.projectDir/src/main/java"
  258. sourceDirectories = files([mainSrc])
  259. classDirectories = files([debugTree])
  260. executionData = fileTree(dir: project.buildDir, includes: [
  261. 'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
  262. ])
  263. }