build.gradle 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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.3.2'
  18. classpath('com.dicedmelon.gradle:jacoco-android:0.1.4') {
  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. exclude group: 'com.google.firebase', module: 'firebase-core'
  30. exclude group: 'com.google.firebase', module: 'firebase-analytics'
  31. exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
  32. // check for updates every build
  33. resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
  34. }
  35. ext {
  36. jacocoVersion = "0.8.2"
  37. travisBuild = System.getenv("TRAVIS") == "true"
  38. // allows for -Dpre-dex=false to be set
  39. preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
  40. }
  41. repositories {
  42. google()
  43. jcenter()
  44. maven { url "https://jitpack.io" }
  45. maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
  46. flatDir {
  47. dirs 'libs'
  48. }
  49. }
  50. // semantic versioning for version code
  51. def versionMajor = 3
  52. def versionMinor = 5
  53. def versionPatch = 0
  54. def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
  55. def taskRequest = getGradle().getStartParameter().getTaskRequests().toString()
  56. if (taskRequest.contains("Gplay") || taskRequest.contains("findbugs") || taskRequest.contains("lint")) {
  57. apply from: 'gplay.gradle'
  58. }
  59. android {
  60. lintOptions {
  61. abortOnError false
  62. htmlReport true
  63. htmlOutput file("$project.buildDir/reports/lint/lint.html")
  64. disable 'MissingTranslation', 'GradleDependency', 'VectorPath', 'IconMissingDensityFolder', 'IconDensities'
  65. }
  66. dexOptions {
  67. javaMaxHeapSize "4g"
  68. }
  69. compileSdkVersion 28
  70. defaultConfig {
  71. minSdkVersion 14
  72. targetSdkVersion 28
  73. // arguments to be passed to functional tests
  74. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  75. testInstrumentationRunnerArgument "TEST_SERVER_URL", "${NC_TEST_SERVER_BASEURL}"
  76. testInstrumentationRunnerArgument "TEST_SERVER_USERNAME", "${NC_TEST_SERVER_USERNAME}"
  77. testInstrumentationRunnerArgument "TEST_SERVER_PASSWORD", "${NC_TEST_SERVER_PASSWORD}"
  78. multiDexEnabled true
  79. versionCode versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
  80. if (versionBuild > 89) {
  81. versionName "${versionMajor}.${versionMinor}.${versionPatch}"
  82. } else if (versionBuild > 50) {
  83. versionName "${versionMajor}.${versionMinor}.${versionPatch} RC" + (versionBuild - 50)
  84. } else {
  85. versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha" + (versionBuild + 1)
  86. }
  87. // adapt structure from Eclipse to Gradle/Android Studio expectations;
  88. // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
  89. flavorDimensions "default"
  90. buildTypes {
  91. debug {
  92. testCoverageEnabled true
  93. }
  94. }
  95. productFlavors {
  96. // used for f-droid
  97. generic {
  98. applicationId 'com.nextcloud.client'
  99. dimension "default"
  100. }
  101. gplay {
  102. applicationId 'com.nextcloud.client'
  103. dimension "default"
  104. }
  105. versionDev {
  106. applicationId "com.nextcloud.android.beta"
  107. dimension "default"
  108. versionCode 20190328
  109. versionName "20190328"
  110. }
  111. }
  112. }
  113. // adapt structure from Eclipse to Gradle/Android Studio expectations;
  114. // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
  115. dexOptions {
  116. // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
  117. preDexLibraries = preDexEnabled && !travisBuild
  118. }
  119. packagingOptions {
  120. exclude 'META-INF/LICENSE.txt'
  121. exclude 'META-INF/LICENSE'
  122. }
  123. tasks.register("checkstyle", Checkstyle) {
  124. configFile = file("${rootProject.projectDir}/checkstyle.xml")
  125. configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
  126. source 'src'
  127. include '**/*.java'
  128. exclude '**/gen/**'
  129. classpath = files()
  130. }
  131. tasks.register("pmd", Pmd) {
  132. ruleSetFiles = files("${project.rootDir}/pmd-ruleset.xml")
  133. ignoreFailures = false
  134. ruleSets = []
  135. source 'src'
  136. include '**/*.java'
  137. exclude '**/gen/**'
  138. reports {
  139. xml.enabled = false
  140. html.enabled = true
  141. xml {
  142. destination = file("$project.buildDir/reports/pmd/pmd.xml")
  143. }
  144. html {
  145. destination = file("$project.buildDir/reports/pmd/pmd.html")
  146. }
  147. }
  148. }
  149. tasks.register("findbugs", FindBugs) {
  150. ignoreFailures = false
  151. effort = "max"
  152. reportLevel = "medium"
  153. classes = fileTree("$project.buildDir/intermediates/javac/gplayDebug/compileGplayDebugJavaWithJavac/classes/")
  154. excludeFilter = file("${project.rootDir}/findbugs-filter.xml")
  155. source = fileTree('src/main/java')
  156. pluginClasspath = project.configurations.findbugsPlugins
  157. classpath = files()
  158. include '**/*.java'
  159. exclude '**/gen/**'
  160. reports {
  161. xml.enabled = false
  162. html.enabled = true
  163. html {
  164. destination = file("$project.buildDir/reports/findbugs/findbugs.html")
  165. }
  166. }
  167. }
  168. check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
  169. compileOptions {
  170. sourceCompatibility JavaVersion.VERSION_1_8
  171. targetCompatibility JavaVersion.VERSION_1_8
  172. }
  173. }
  174. dependencies {
  175. // dependencies for app building
  176. implementation 'androidx.multidex:multidex:2.0.1'
  177. // implementation project('nextcloud-android-library')
  178. genericImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
  179. gplayImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
  180. versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
  181. implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
  182. implementation 'androidx.legacy:legacy-support-v4:1.0.0'
  183. implementation 'com.google.android.material:material:1.0.0'
  184. implementation 'com.jakewharton:disklrucache:2.0.2'
  185. implementation 'androidx.appcompat:appcompat:1.0.2'
  186. implementation 'androidx.cardview:cardview:1.0.0'
  187. implementation 'androidx.exifinterface:exifinterface:1.0.0'
  188. implementation 'com.github.albfernandez:juniversalchardet:2.0.3' // need this version for Android <7
  189. implementation 'com.google.code.findbugs:annotations:2.0.1'
  190. implementation 'commons-io:commons-io:2.6'
  191. implementation 'com.github.tobiaskaminsky:android-job:v1.2.6.1' // 'com.github.evernote:android-job:v1.2.5'
  192. implementation 'com.jakewharton:butterknife:10.1.0'
  193. annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
  194. implementation 'org.greenrobot:eventbus:3.1.1'
  195. implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5'
  196. implementation 'org.lukhnos:nnio:0.2'
  197. implementation 'com.madgag.spongycastle:pkix:1.54.0.0'
  198. implementation 'com.google.code.gson:gson:2.8.5'
  199. implementation 'com.afollestad:sectioned-recyclerview:0.5.0'
  200. implementation 'com.github.chrisbanes:PhotoView:2.3.0'
  201. implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15'
  202. implementation 'com.github.tobiaskaminsky:qrcodescanner:0.1.2.2' // 'com.github.blikoon:QRCodeScanner:0.1.2'
  203. implementation 'com.google.android:flexbox:1.1.0'
  204. implementation 'org.parceler:parceler-api:1.1.12'
  205. annotationProcessor 'org.parceler:parceler:1.1.12'
  206. implementation('com.github.bumptech.glide:glide:3.7.0') {
  207. exclude group: "com.android.support"
  208. }
  209. implementation 'com.caverock:androidsvg:1.3'
  210. implementation 'androidx.annotation:annotation:1.0.2'
  211. implementation 'com.google.code.gson:gson:2.8.5'
  212. // dependencies for local unit tests
  213. testImplementation 'junit:junit:4.12'
  214. testImplementation 'org.mockito:mockito-core:2.25.1'
  215. testImplementation 'androidx.test:core:1.1.0'
  216. // dependencies for instrumented tests
  217. // JUnit4 Rules
  218. androidTestImplementation 'androidx.test.ext:junit:1.1.0'
  219. androidTestImplementation 'androidx.test:rules:1.1.1'
  220. // Android JUnit Runner
  221. androidTestImplementation 'androidx.test:runner:1.1.1'
  222. // Espresso core
  223. androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
  224. androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.1'
  225. // UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
  226. // androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
  227. // fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
  228. //androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
  229. implementation 'org.jetbrains:annotations:17.0.0'
  230. compileOnly "org.projectlombok:lombok:1.18.6"
  231. annotationProcessor "org.projectlombok:lombok:1.18.6"
  232. androidTestImplementation 'tools.fastlane:screengrab:1.2.0'
  233. findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.9.0'
  234. findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.3'
  235. implementation 'com.google.dagger:dagger:2.21'
  236. implementation 'com.google.dagger:dagger-android:2.21'
  237. implementation 'com.google.dagger:dagger-android-support:2.21'
  238. annotationProcessor 'com.google.dagger:dagger-compiler:2.21'
  239. annotationProcessor 'com.google.dagger:dagger-android-processor:2.21'
  240. // jacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
  241. // jacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  242. // androidJacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  243. // androidJacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
  244. // androidJacocoAnt "org.jacoco:org.jacoco.core:${jacocoVersion}"
  245. // androidJacocoAnt "org.jacoco:org.jacoco.report:${jacocoVersion}"
  246. // androidJacocoAnt "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  247. }
  248. configurations.all {
  249. resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
  250. }
  251. tasks.withType(Test) {
  252. // increased logging for tests
  253. testLogging {
  254. events "passed", "skipped", "failed"
  255. }
  256. }
  257. android.applicationVariants.all { variant ->
  258. variant.outputs.all { output ->
  259. outputFileName = "${output.baseName}-${variant.versionCode}.apk"
  260. }
  261. }
  262. tasks.register("combinedTestReport", JacocoReport) {
  263. reports {
  264. xml.enabled = true
  265. html.enabled = true
  266. }
  267. def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
  268. def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/gplay/debug", excludes: fileFilter)
  269. def mainSrc = "$project.projectDir/src/main/java"
  270. sourceDirectories = files([mainSrc])
  271. classDirectories = files([debugTree])
  272. executionData = fileTree(dir: project.buildDir, includes: [
  273. 'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
  274. ])
  275. }