build.gradle 11 KB

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