123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474 |
- import com.github.spotbugs.snom.SpotBugsTask
- // Gradle build file
- //
- // This project was started in Eclipse and later moved to Android Studio. In the transition, both IDEs were supported.
- // Due to this, the files layout is not the usual in new projects created with Android Studio / gradle. This file
- // merges declarations usually split in two separates build.gradle file, one for global settings of the project in
- // its root folder, another one for the app module in subfolder of root.
- buildscript {
- ext.kotlin_version = '1.4.10'
- repositories {
- google()
- jcenter()
- maven {
- url 'https://oss.sonatype.org/content/repositories/snapshots/'
- }
- maven {
- url 'https://plugins.gradle.org/m2/'
- }
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:4.1.0'
- classpath('com.hiya:jacoco-android:0.2')
- classpath 'gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.5.1'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.14.2"
- classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
- classpath 'com.karumi:shot:4.4.0'
- }
- }
- apply plugin: 'com.android.application'
- apply plugin: 'kotlin-android'
- apply plugin: 'kotlin-android-extensions'
- apply plugin: 'kotlin-kapt'
- apply plugin: 'checkstyle'
- apply plugin: 'pmd'
- apply plugin: 'com.hiya.jacoco-android'
- apply plugin: 'com.github.spotbugs'
- apply plugin: 'io.gitlab.arturbosch.detekt'
- apply plugin: 'shot'
- configurations {
- ktlint
- all {
- exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitly
- // check for updates every build
- resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
- }
- }
- ext {
- jacocoVersion = "0.8.2"
- daggerVersion = "2.29.1"
- markwonVersion = "4.6.0"
- prismVersion = "2.0.0"
- butterknifeVersion = "10.2.3"
- androidLibraryVersion = "master-SNAPSHOT"
- mockitoVersion = "3.5.15"
- mockkVersion = "1.10.2"
- byteBuddyVersion = "1.10.17"
- espressoVersion = "3.3.0"
- travisBuild = System.getenv("TRAVIS") == "true"
- // allows for -D pre-dex=false to be set
- preDexEnabled = "true" == System.getProperty("pre-dex", "true")
- }
- repositories {
- google()
- jcenter()
- maven { url "https://jitpack.io" }
- maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
- flatDir {
- dirs 'libs'
- }
- }
- // semantic versioning for version code
- def versionMajor = 3
- def versionMinor = 14
- def versionPatch = 0
- def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
- for (TaskExecutionRequest tr : getGradle().getStartParameter().getTaskRequests()) {
- for (String arg : tr.args) {
- // any gplay, but only exact "build", as e.g. buildGeneric shall not apply gplay.grade
- if (arg.contains("Gplay") || arg.contains("lint") || arg.contains("ExecuteScreenshot") || arg == "build") {
- apply from: 'gplay.gradle'
- System.console().println("Applying gplay.gradle")
- break
- }
- }
- }
- android {
- lintOptions {
- checkGeneratedSources = true
- abortOnError false
- htmlReport true
- htmlOutput file("$project.buildDir/reports/lint/lint.html")
- disable 'MissingTranslation',
- 'GradleDependency',
- 'VectorPath',
- 'IconMissingDensityFolder',
- 'IconDensities',
- 'GoogleAppIndexingWarning',
- 'MissingDefaultResource',
- 'InvalidPeriodicWorkRequestInterval' // crashes due to a bug in lint itself
- }
- dexOptions {
- javaMaxHeapSize "4g"
- }
- compileSdkVersion 29
- defaultConfig {
- minSdkVersion 19
- targetSdkVersion 29
- // arguments to be passed to functional tests
- testInstrumentationRunner "com.nextcloud.client.ScreenshotTestRunner"
- testInstrumentationRunnerArgument "TEST_SERVER_URL", "${NC_TEST_SERVER_BASEURL}"
- testInstrumentationRunnerArgument "TEST_SERVER_USERNAME", "${NC_TEST_SERVER_USERNAME}"
- testInstrumentationRunnerArgument "TEST_SERVER_PASSWORD", "${NC_TEST_SERVER_PASSWORD}"
- testInstrumentationRunnerArguments disableAnalytics: 'true'
- multiDexEnabled true
- versionCode versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
- if (versionBuild > 89) {
- versionName "${versionMajor}.${versionMinor}.${versionPatch}"
- } else if (versionBuild > 50) {
- versionName "${versionMajor}.${versionMinor}.${versionPatch} RC" + (versionBuild - 50)
- } else {
- versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha" + (versionBuild + 1)
- }
- // adapt structure from Eclipse to Gradle/Android Studio expectations;
- // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
- flavorDimensions "default"
- buildTypes {
- debug {
- testCoverageEnabled (project.hasProperty('coverage'))
- }
- }
- productFlavors {
- // used for f-droid
- generic {
- applicationId 'com.nextcloud.client'
- dimension "default"
- }
- gplay {
- applicationId 'com.nextcloud.client'
- dimension "default"
- }
- versionDev {
- applicationId "com.nextcloud.android.beta"
- dimension "default"
- versionCode 20200129
- versionName "20200129"
- }
- qa {
- applicationId "com.nextcloud.android.qa"
- dimension "default"
- versionCode 1
- versionName "1"
- }
- }
- testOptions {
- unitTests.returnDefaultValues = true
- animationsDisabled true
- }
- }
- // adapt structure from Eclipse to Gradle/Android Studio expectations;
- // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
- dexOptions {
- // Skip pre-dexing when running on Travis CI or when disabled via -D pre-dex=false.
- preDexLibraries = preDexEnabled && !travisBuild
- }
- packagingOptions {
- exclude 'META-INF/LICENSE.txt'
- exclude 'META-INF/LICENSE'
- }
- tasks.register("checkstyle", Checkstyle) {
- configFile = file("${rootProject.projectDir}/checkstyle.xml")
- configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
- source 'src'
- include '**/*.java'
- exclude '**/gen/**'
- classpath = files()
- }
- tasks.register("pmd", Pmd) {
- ruleSetFiles = files("${project.rootDir}/ruleset.xml")
- ignoreFailures = true // should continue checking
- ruleSets = []
- source 'src'
- include '**/*.java'
- exclude '**/gen/**'
- reports {
- xml.enabled = false
- html.enabled = true
- xml {
- destination = file("$project.buildDir/reports/pmd/pmd.xml")
- }
- html {
- destination = file("$project.buildDir/reports/pmd/pmd.html")
- }
- }
- }
- android.applicationVariants.all { variant ->
- String variantName = variant.name
- String capVariantName = variantName.substring(0, 1).toUpperCase() + variantName.substring(1)
- tasks.register("spotbugs${capVariantName}Report", SpotBugsTask) {
- ignoreFailures = true // should continue checking
- effort = "max"
- reportLevel = "medium"
- classes = fileTree("$project.buildDir/intermediates/javac/${variantName}/classes/")
- excludeFilter = file("${project.rootDir}/spotbugs-filter.xml")
- reports {
- xml.enabled = false
- html {
- enabled = true
- destination = file("$project.buildDir/reports/spotbugs/spotbugs.html")
- }
- }
- }
- }
- check.dependsOn 'checkstyle', 'spotbugsGplayDebugReport', 'pmd', 'lint', 'ktlint', 'detekt'
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- buildFeatures {
- dataBinding true
- viewBinding true
- }
- }
- dependencies {
- // dependencies for app building
- implementation 'androidx.multidex:multidex:2.0.1'
- // implementation project('nextcloud-android-library')
- genericImplementation "com.github.nextcloud:android-library:$androidLibraryVersion"
- gplayImplementation "com.github.nextcloud:android-library:$androidLibraryVersion"
- versionDevImplementation "com.github.nextcloud:android-library:$androidLibraryVersion"
- qaImplementation "com.github.nextcloud:android-library:$androidLibraryVersion"
- kapt 'javax.xml.bind:jaxb-api:2.3.1'
- kapt 'org.glassfish.jaxb:jaxb-core:2.3.0.1'
- kapt 'org.glassfish.jaxb:jaxb-runtime:2.3.3'
- annotationProcessor 'javax.xml.bind:jaxb-api:2.3.1'
- annotationProcessor 'org.glassfish.jaxb:jaxb-core:2.3.0.1'
- annotationProcessor 'org.glassfish.jaxb:jaxb-runtime:2.3.3'
- compileOnly 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' // remove after entire switch to lib v2
- implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
- implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.1' // remove after entire switch to lib v2
- implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
- implementation 'androidx.legacy:legacy-support-v4:1.0.0'
- implementation 'com.google.android.material:material:1.2.1'
- implementation 'com.jakewharton:disklrucache:2.0.2'
- implementation 'androidx.appcompat:appcompat:1.2.0-rc01'
- implementation 'androidx.cardview:cardview:1.0.0'
- implementation 'androidx.exifinterface:exifinterface:1.3.1'
- implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
- implementation "androidx.work:work-runtime:2.4.0"
- implementation "androidx.work:work-runtime-ktx:2.4.0"
- implementation "androidx.fragment:fragment:1.2.5"
- implementation 'com.github.albfernandez:juniversalchardet:2.0.3' // need this version for Android <7
- compileOnly 'com.google.code.findbugs:annotations:2.0.1'
- implementation 'commons-io:commons-io:2.8.0'
- implementation "com.jakewharton:butterknife:$butterknifeVersion"
- kapt "com.jakewharton:butterknife-compiler:$butterknifeVersion"
- implementation 'org.greenrobot:eventbus:3.2.0'
- implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.0'
- implementation 'org.lukhnos:nnio:0.2'
- implementation 'org.bouncycastle:bcpkix-jdk15on:1.65'
- implementation 'com.google.code.gson:gson:2.8.6'
- implementation 'com.afollestad:sectioned-recyclerview:0.5.0'
- implementation 'com.github.chrisbanes:PhotoView:2.3.0'
- implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.21'
- implementation 'com.github.tobiaskaminsky:qrcodescanner:0.1.2.2' // 'com.github.blikoon:QRCodeScanner:0.1.2'
- implementation 'com.google.android:flexbox:2.0.1'
- implementation 'org.parceler:parceler-api:1.1.13'
- kapt 'org.parceler:parceler:1.1.13'
- implementation('com.github.bumptech.glide:glide:3.8.0') {
- exclude group: "com.android.support"
- }
- implementation 'com.caverock:androidsvg:1.4'
- implementation 'androidx.annotation:annotation:1.1.0'
- implementation 'com.google.code.gson:gson:2.8.6'
- implementation 'com.github.cotechde.hwsecurity:hwsecurity-fido:4.1.0'
- implementation 'com.github.cotechde.hwsecurity:hwsecurity-fido2:4.1.0'
- spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.1'
- spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.7'
- implementation "com.google.dagger:dagger:$daggerVersion"
- implementation "com.google.dagger:dagger-android:$daggerVersion"
- implementation "com.google.dagger:dagger-android-support:$daggerVersion"
- kapt "com.google.dagger:dagger-compiler:$daggerVersion"
- kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
- ktlint "com.pinterest:ktlint:0.39.0"
- implementation 'org.conscrypt:conscrypt-android:2.5.1'
- // Shimmer animation
- implementation 'com.elyeproj.libraries:loaderviewlibrary:2.0.0'
- // dependencies for markdown rendering
- implementation "io.noties.markwon:core:$markwonVersion"
- implementation "io.noties.markwon:ext-strikethrough:$markwonVersion"
- implementation "io.noties.markwon:ext-tables:$markwonVersion"
- implementation "io.noties.markwon:ext-tasklist:$markwonVersion"
- implementation "io.noties.markwon:html:$markwonVersion"
- implementation "io.noties.markwon:syntax-highlight:$markwonVersion"
- implementation "io.noties:prism4j:$prismVersion"
- kapt "io.noties:prism4j-bundler:$prismVersion"
- // dependencies for local unit tests
- testImplementation 'junit:junit:4.13.1'
- testImplementation "org.mockito:mockito-core:$mockitoVersion"
- testImplementation 'androidx.test:core:1.3.0'
- testImplementation 'org.powermock:powermock-core:2.0.7'
- testImplementation 'org.powermock:powermock-module-junit4:2.0.7'
- testImplementation 'org.powermock:powermock-api-mockito2:2.0.7'
- testImplementation 'org.json:json:20200518'
- testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
- testImplementation 'androidx.arch.core:core-testing:2.1.0'
- testImplementation "io.mockk:mockk:$mockkVersion"
- testImplementation "io.mockk:mockk-android:$mockkVersion"
- // dependencies for instrumented tests
- // JUnit4 Rules
- androidTestImplementation 'androidx.test.ext:junit:1.1.2'
- androidTestImplementation 'androidx.test:rules:1.3.0'
- // Android JUnit Runner
- androidTestImplementation 'androidx.test:runner:1.3.0'
- androidTestUtil 'androidx.test:orchestrator:1.3.0'
- // Espresso core
- androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
- androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
- androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion"
- // Mocking support
- androidTestImplementation 'com.github.tmurakami:dexopener:2.0.5' // required to allow mocking on API 27 and older
- androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
- androidTestImplementation "org.mockito:mockito-core:$mockitoVersion"
- androidTestImplementation("org.mockito:mockito-android:$mockitoVersion") {
- exclude group: "net.bytebuddy", module: "byte-buddy-android"
- }
- androidTestImplementation "net.bytebuddy:byte-buddy:$byteBuddyVersion"
- androidTestImplementation "net.bytebuddy:byte-buddy-android:$byteBuddyVersion"
- androidTestImplementation "io.mockk:mockk-android:1.10.0"
- androidTestImplementation 'androidx.arch.core:core-testing:2.0.1'
- // UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
- // androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
- // fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
- //androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
- androidTestImplementation 'tools.fastlane:screengrab:2.0.0'
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
- androidTestImplementation('com.android.support.test.espresso:espresso-intents:3.0.2')
- // jacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
- // jacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
- // androidJacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
- // androidJacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
- // androidJacocoAnt "org.jacoco:org.jacoco.core:${jacocoVersion}"
- // androidJacocoAnt "org.jacoco:org.jacoco.report:${jacocoVersion}"
- // androidJacocoAnt "org.jacoco:org.jacoco.agent:${jacocoVersion}"
- implementation "com.github.stateless4j:stateless4j:2.6.0"
- }
- spotbugs {
- toolVersion = '3.1.12'
- }
- configurations.all {
- resolutionStrategy{
- cacheChangingModulesFor 0, 'seconds'
- force 'org.objenesis:objenesis:2.6'
- }
- }
- tasks.withType(Test) {
- // increased logging for tests
- testLogging {
- events "passed", "skipped", "failed"
- }
- }
- android.applicationVariants.all { variant ->
- variant.outputs.all { output ->
- outputFileName = "${output.baseName}-${variant.versionCode}.apk"
- }
- }
- tasks.register("combinedTestReport", JacocoReport) {
- reports {
- xml.enabled true
- html.enabled true
- csv.enabled false
- }
- additionalSourceDirs.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
- sourceDirectories.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
- classDirectories.setFrom files(subprojects.sourceSets.main.output)
- executionData.setFrom project.fileTree(dir: project.buildDir, includes: [
- 'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
- ])
- }
- task ktlint(type: JavaExec, group: "verification") {
- description = "Check Kotlin code style."
- main = "com.pinterest.ktlint.Main"
- classpath = configurations.ktlint
- args "--reporter=plain", "--reporter=plain,output=${buildDir}/ktlint.txt,src/**/*.kt"
- }
- task ktlintFormat(type: JavaExec, group: "formatting") {
- description = "Fix Kotlin code style deviations."
- main = "com.pinterest.ktlint.Main"
- classpath = configurations.ktlint
- args "-F", "src/**/*.kt"
- }
- detekt {
- reports {
- xml {
- enabled = false
- }
- }
- config = files("detekt.yml")
- input = files("src/")
- }
|