build.gradle 13 KB

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