build.gradle 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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.1'
  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 20190515
  122. versionName "20190515"
  123. }
  124. qa {
  125. applicationId "com.nextcloud.android.qa"
  126. dimension "default"
  127. versionCode 1
  128. versionName "1"
  129. }
  130. }
  131. }
  132. // adapt structure from Eclipse to Gradle/Android Studio expectations;
  133. // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
  134. dexOptions {
  135. // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
  136. preDexLibraries = preDexEnabled && !travisBuild
  137. }
  138. packagingOptions {
  139. exclude 'META-INF/LICENSE.txt'
  140. exclude 'META-INF/LICENSE'
  141. }
  142. tasks.register("checkstyle", Checkstyle) {
  143. configFile = file("${rootProject.projectDir}/checkstyle.xml")
  144. configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
  145. source 'src'
  146. include '**/*.java'
  147. exclude '**/gen/**'
  148. classpath = files()
  149. }
  150. tasks.register("pmd", Pmd) {
  151. ruleSetFiles = files("${project.rootDir}/ruleset.xml")
  152. ignoreFailures = false
  153. ruleSets = []
  154. source 'src'
  155. include '**/*.java'
  156. exclude '**/gen/**'
  157. reports {
  158. xml.enabled = false
  159. html.enabled = true
  160. xml {
  161. destination = file("$project.buildDir/reports/pmd/pmd.xml")
  162. }
  163. html {
  164. destination = file("$project.buildDir/reports/pmd/pmd.html")
  165. }
  166. }
  167. }
  168. tasks.register("findbugs", FindBugs) {
  169. ignoreFailures = false
  170. effort = "max"
  171. reportLevel = "medium"
  172. classes = fileTree("$project.buildDir/intermediates/javac/gplayDebug/compileGplayDebugJavaWithJavac/classes/")
  173. excludeFilter = file("${project.rootDir}/findbugs-filter.xml")
  174. source = fileTree('src/main/java')
  175. pluginClasspath = project.configurations.findbugsPlugins
  176. classpath = files()
  177. include '**/*.java'
  178. exclude '**/gen/**'
  179. reports {
  180. xml.enabled = false
  181. html.enabled = true
  182. html {
  183. destination = file("$project.buildDir/reports/findbugs/findbugs.html")
  184. }
  185. }
  186. }
  187. android.applicationVariants.all { variant ->
  188. String variantName = variant.name
  189. String capVariantName = variantName.substring(0, 1).toUpperCase() + variantName.substring(1)
  190. tasks.register("spotbugs${capVariantName}", SpotBugsTask) {
  191. ignoreFailures = false
  192. effort = "max"
  193. reportLevel = "medium"
  194. classes = fileTree("$project.buildDir/intermediates/javac/${variantName}/compile${capVariantName}JavaWithJavac/classes/")
  195. excludeFilter = file("${project.rootDir}/findbugs-filter.xml")
  196. pluginClasspath = project.configurations.spotbugsPlugins
  197. source = fileTree('src/main/java')
  198. classpath = files()
  199. include '**/*.java'
  200. exclude '**/gen/**'
  201. reports {
  202. xml.enabled = false
  203. html.enabled = true
  204. html {
  205. destination = file("$project.buildDir/reports/spotbugs/spotbugs.html")
  206. }
  207. }
  208. }
  209. }
  210. check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
  211. compileOptions {
  212. sourceCompatibility JavaVersion.VERSION_1_8
  213. targetCompatibility JavaVersion.VERSION_1_8
  214. }
  215. }
  216. dependencies {
  217. // dependencies for app building
  218. implementation 'androidx.multidex:multidex:2.0.1'
  219. // implementation project('nextcloud-android-library')
  220. genericImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
  221. gplayImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
  222. versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
  223. qaImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
  224. implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
  225. implementation 'androidx.legacy:legacy-support-v4:1.0.0'
  226. implementation 'com.google.android.material:material:1.0.0'
  227. implementation 'com.jakewharton:disklrucache:2.0.2'
  228. implementation 'androidx.appcompat:appcompat:1.0.2'
  229. implementation 'androidx.cardview:cardview:1.0.0'
  230. implementation 'androidx.exifinterface:exifinterface:1.0.0'
  231. implementation 'com.github.albfernandez:juniversalchardet:2.0.3' // need this version for Android <7
  232. implementation 'com.google.code.findbugs:annotations:2.0.1'
  233. implementation 'commons-io:commons-io:2.6'
  234. implementation 'com.github.tobiaskaminsky:android-job:v1.2.6.1' // 'com.github.evernote:android-job:v1.2.5'
  235. implementation 'com.jakewharton:butterknife:10.1.0'
  236. annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
  237. implementation 'org.greenrobot:eventbus:3.1.1'
  238. implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5'
  239. implementation 'org.lukhnos:nnio:0.2'
  240. implementation 'com.madgag.spongycastle:pkix:1.54.0.0'
  241. implementation 'com.google.code.gson:gson:2.8.5'
  242. implementation 'com.afollestad:sectioned-recyclerview:0.5.0'
  243. implementation 'com.github.chrisbanes:PhotoView:2.3.0'
  244. implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15'
  245. implementation 'com.github.tobiaskaminsky:qrcodescanner:0.1.2.2' // 'com.github.blikoon:QRCodeScanner:0.1.2'
  246. implementation 'com.google.android:flexbox:1.1.0'
  247. implementation 'org.parceler:parceler-api:1.1.12'
  248. annotationProcessor 'org.parceler:parceler:1.1.12'
  249. implementation('com.github.bumptech.glide:glide:3.7.0') {
  250. exclude group: "com.android.support"
  251. }
  252. implementation 'com.caverock:androidsvg:1.3'
  253. implementation 'androidx.annotation:annotation:1.0.2'
  254. implementation 'com.google.code.gson:gson:2.8.5'
  255. implementation 'org.jetbrains:annotations:17.0.0'
  256. spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.9.0'
  257. spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.5'
  258. implementation 'com.google.dagger:dagger:2.22.1'
  259. implementation 'com.google.dagger:dagger-android:2.22.1'
  260. implementation 'com.google.dagger:dagger-android-support:2.22.1'
  261. annotationProcessor 'com.google.dagger:dagger-compiler:2.22.1'
  262. annotationProcessor 'com.google.dagger:dagger-android-processor:2.22.1'
  263. compileOnly "org.projectlombok:lombok:1.18.8"
  264. annotationProcessor "org.projectlombok:lombok:1.18.8"
  265. // dependencies for local unit tests
  266. testImplementation 'junit:junit:4.12'
  267. testImplementation 'org.mockito:mockito-core:2.27.0'
  268. testImplementation 'androidx.test:core:1.1.0'
  269. testImplementation 'org.powermock:powermock-core:2.0.2'
  270. testImplementation 'org.powermock:powermock-module-junit4:2.0.2'
  271. testImplementation 'org.powermock:powermock-api-mockito2:2.0.2'
  272. testImplementation 'org.json:json:20180813'
  273. // dependencies for instrumented tests
  274. // JUnit4 Rules
  275. androidTestImplementation 'androidx.test.ext:junit:1.1.0'
  276. androidTestImplementation 'androidx.test:rules:1.1.1'
  277. // Android JUnit Runner
  278. androidTestImplementation 'androidx.test:runner:1.1.1'
  279. // Espresso core
  280. androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
  281. androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.1'
  282. androidTestImplementation 'org.mockito:mockito-core:2.27.0'
  283. // UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
  284. // androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
  285. // fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
  286. //androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
  287. androidTestImplementation 'tools.fastlane:screengrab:1.2.0'
  288. implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  289. // jacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
  290. // jacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  291. // androidJacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  292. // androidJacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
  293. // androidJacocoAnt "org.jacoco:org.jacoco.core:${jacocoVersion}"
  294. // androidJacocoAnt "org.jacoco:org.jacoco.report:${jacocoVersion}"
  295. // androidJacocoAnt "org.jacoco:org.jacoco.agent:${jacocoVersion}"
  296. }
  297. configurations.all {
  298. resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
  299. }
  300. tasks.withType(Test) {
  301. // increased logging for tests
  302. testLogging {
  303. events "passed", "skipped", "failed"
  304. }
  305. }
  306. android.applicationVariants.all { variant ->
  307. variant.outputs.all { output ->
  308. outputFileName = "${output.baseName}-${variant.versionCode}.apk"
  309. }
  310. }
  311. tasks.register("combinedTestReport", JacocoReport) {
  312. reports {
  313. xml.enabled = true
  314. html.enabled = true
  315. }
  316. def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
  317. def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/gplay/debug", excludes: fileFilter)
  318. def mainSrc = "$project.projectDir/src/main/java"
  319. sourceDirectories = files([mainSrc])
  320. classDirectories = files([debugTree])
  321. executionData = fileTree(dir: project.buildDir, includes: [
  322. 'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
  323. ])
  324. }