build.gradle 14 KB

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