build.gradle 11 KB

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