nextcloud-android/build.gradle

482 lines
17 KiB
Groovy
Raw Normal View History

import com.github.spotbugs.snom.SpotBugsTask
2021-05-14 16:27:44 +03:00
import org.gradle.internal.jvm.Jvm
// 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.6.0'
ext.jacoco_version = '0.8.7'
repositories {
google()
maven {
url 'https://plugins.gradle.org/m2/'
}
2018-08-22 18:42:15 +03:00
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.hiya:jacoco-android:0.2'
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:4.8.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.19.0"
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
classpath 'com.karumi:shot:5.11.2'
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
classpath "org.jacoco:org.jacoco.report:$jacoco_version"
classpath "org.jacoco:org.jacoco.agent:$jacoco_version"
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
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'
2021-05-14 16:27:44 +03:00
println "Gradle uses Java ${Jvm.current()}"
configurations {
ktlint
2019-02-17 15:29:27 +03:00
all {
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitly
// check for updates every build
resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"
}
}
2017-03-06 16:16:31 +03:00
}
ext {
androidxTestVersion = "1.4.0"
Bump daggerVersion from 2.40.1 to 2.40.2 Bumps `daggerVersion` from 2.40.1 to 2.40.2. Updates `dagger` from 2.40.1 to 2.40.2 - [Release notes](https://github.com/google/dagger/releases) - [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/dagger/compare/dagger-2.40.1...dagger-2.40.2) Updates `dagger-android` from 2.40.1 to 2.40.2 - [Release notes](https://github.com/google/dagger/releases) - [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/dagger/compare/dagger-2.40.1...dagger-2.40.2) Updates `dagger-android-support` from 2.40.1 to 2.40.2 - [Release notes](https://github.com/google/dagger/releases) - [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/dagger/compare/dagger-2.40.1...dagger-2.40.2) Updates `dagger-compiler` from 2.40.1 to 2.40.2 - [Release notes](https://github.com/google/dagger/releases) - [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/dagger/compare/dagger-2.40.1...dagger-2.40.2) Updates `dagger-android-processor` from 2.40.1 to 2.40.2 - [Release notes](https://github.com/google/dagger/releases) - [Changelog](https://github.com/google/dagger/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/dagger/compare/dagger-2.40.1...dagger-2.40.2) --- updated-dependencies: - dependency-name: com.google.dagger:dagger dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.google.dagger:dagger-android dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.google.dagger:dagger-android-support dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.google.dagger:dagger-compiler dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.google.dagger:dagger-android-processor dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
2021-11-25 11:47:32 +03:00
daggerVersion = "2.40.2"
Bump markwonVersion from 4.6.1 to 4.6.2 Bumps `markwonVersion` from 4.6.1 to 4.6.2. Updates `core` from 4.6.1 to 4.6.2 - [Release notes](https://github.com/noties/Markwon/releases) - [Changelog](https://github.com/noties/Markwon/blob/master/CHANGELOG.md) - [Commits](https://github.com/noties/Markwon/compare/v4.6.1...v4.6.2) Updates `ext-strikethrough` from 4.6.1 to 4.6.2 - [Release notes](https://github.com/noties/Markwon/releases) - [Changelog](https://github.com/noties/Markwon/blob/master/CHANGELOG.md) - [Commits](https://github.com/noties/Markwon/compare/v4.6.1...v4.6.2) Updates `ext-tables` from 4.6.1 to 4.6.2 - [Release notes](https://github.com/noties/Markwon/releases) - [Changelog](https://github.com/noties/Markwon/blob/master/CHANGELOG.md) - [Commits](https://github.com/noties/Markwon/compare/v4.6.1...v4.6.2) Updates `ext-tasklist` from 4.6.1 to 4.6.2 - [Release notes](https://github.com/noties/Markwon/releases) - [Changelog](https://github.com/noties/Markwon/blob/master/CHANGELOG.md) - [Commits](https://github.com/noties/Markwon/compare/v4.6.1...v4.6.2) Updates `html` from 4.6.1 to 4.6.2 - [Release notes](https://github.com/noties/Markwon/releases) - [Changelog](https://github.com/noties/Markwon/blob/master/CHANGELOG.md) - [Commits](https://github.com/noties/Markwon/compare/v4.6.1...v4.6.2) Updates `syntax-highlight` from 4.6.1 to 4.6.2 - [Release notes](https://github.com/noties/Markwon/releases) - [Changelog](https://github.com/noties/Markwon/blob/master/CHANGELOG.md) - [Commits](https://github.com/noties/Markwon/compare/v4.6.1...v4.6.2) Signed-off-by: dependabot[bot] <support@github.com>
2021-02-09 05:04:50 +03:00
markwonVersion = "4.6.2"
prismVersion = "2.0.0"
androidLibraryVersion = "master-SNAPSHOT"
mockitoVersion = "3.12.4"
mockkVersion = "1.12.1"
powermockVersion = "2.0.9"
byteBuddyVersion = "1.12.2"
espressoVersion = "3.4.0"
workRuntime = "2.5.0"
fidoVersion = "4.1.0"
2016-08-16 18:22:22 +03:00
ciBuild = System.getenv("CI") == "true"
}
repositories {
google()
maven { url "https://jitpack.io" }
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
// semantic versioning for version code
def versionMajor = 3
def versionMinor = 19
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")
}
}
}
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
}
2017-02-22 02:46:47 +03:00
compileSdkVersion 31
2015-11-28 13:26:58 +03:00
2016-05-05 09:46:47 +03:00
defaultConfig {
minSdkVersion 23
targetSdkVersion 30
2017-12-21 11:47:10 +03:00
// 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'
2017-02-22 02:40:03 +03:00
multiDexEnabled true
2016-05-05 09:46:47 +03:00
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)
}
2017-10-06 11:41:15 +03:00
// 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 {
2017-04-26 22:11:27 +03:00
// used for f-droid
generic {
applicationId 'com.nextcloud.client'
dimension "default"
}
gplay {
applicationId 'com.nextcloud.client'
dimension "default"
}
2017-04-13 10:14:19 +03:00
versionDev {
applicationId "com.nextcloud.android.beta"
dimension "default"
versionCode 20200129
versionName "20200129"
2017-04-13 10:14:19 +03:00
}
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
packagingOptions {
exclude 'META-INF/LICENSE.txt'
2017-04-12 15:34:43 +03:00
exclude 'META-INF/LICENSE'
}
2017-02-25 05:00:36 +03:00
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")
}
}
}
check.dependsOn 'checkstyle', 'spotbugsGplayDebugReport', 'pmd', 'lint', 'ktlint', 'detekt'
buildFeatures {
dataBinding true
viewBinding true
}
kotlinOptions {
jvmTarget = "1.8"
}
2016-06-24 01:18:45 +03:00
}
dependencies {
// dependencies for app building
implementation 'androidx.multidex:multidex:2.0.1'
2017-12-15 13:36:55 +03:00
// implementation project('nextcloud-android-library')
implementation ("com.github.nextcloud:android-library:$androidLibraryVersion") {
exclude group: 'org.ogce', module: 'xpp3' // unused in Android and brings wrong Junit version
}
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.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.jakewharton:disklrucache:2.0.2'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.webkit:webkit:1.4.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.3.3'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
implementation "androidx.work:work-runtime:$workRuntime"
implementation "androidx.work:work-runtime-ktx:$workRuntime"
implementation "androidx.fragment:fragment-ktx:1.3.6"
implementation 'com.github.albfernandez:juniversalchardet:2.0.3' // need this version for Android <7
compileOnly 'com.google.code.findbugs:annotations:3.0.1u2'
implementation 'commons-io:commons-io:2.11.0'
implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
implementation 'org.lukhnos:nnio:0.2'
implementation 'org.bouncycastle:bcpkix-jdk15to18:1.69'
implementation 'com.google.code.gson:gson:2.8.9'
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.3.0'
implementation 'com.vanniktech:emoji-google:0.8.0'
implementation "com.github.cotechde.hwsecurity:hwsecurity-fido:$fidoVersion"
implementation "com.github.cotechde.hwsecurity:hwsecurity-fido2:$fidoVersion"
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0'
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.43.0"
implementation 'org.conscrypt:conscrypt-android:2.5.2'
implementation 'com.google.android.exoplayer:exoplayer:2.16.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"
implementation ('org.mnode.ical4j:ical4j:1.0.6') {
['org.apache.commons','commons-logging'].each {
exclude group: "$it"
}
}
if (!ciBuild) {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
}
// dependencies for local unit tests
testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "androidx.test:core:$androidxTestVersion"
testImplementation "org.powermock:powermock-core:$powermockVersion"
testImplementation "org.powermock:powermock-module-junit4:$powermockVersion"
testImplementation "org.powermock:powermock-api-mockito2:$powermockVersion"
testImplementation 'org.json:json:20210307'
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.3'
androidTestImplementation "androidx.test:rules:$androidxTestVersion"
// Android JUnit Runner
androidTestImplementation "androidx.test:runner:$androidxTestVersion"
androidTestUtil "androidx.test:orchestrator:$androidxTestVersion"
// Espresso core
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-accessibility:$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:$mockkVersion"
androidTestImplementation 'androidx.arch.core:core-testing:2.0.1'
androidTestImplementation "com.facebook.testing.screenshot:core:0.13.0"
// 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.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
androidTestImplementation('com.android.support.test.espresso:espresso-intents:3.0.2')
implementation "com.github.stateless4j:stateless4j:2.6.0"
}
configurations.all {
resolutionStrategy{
cacheChangingModulesFor 0, 'seconds'
force 'org.objenesis:objenesis:2.6'
eachDependency { details ->
if ('org.jacoco' == details.requested.group) {
details.useVersion "$jacoco_version"
}
}
}
}
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) {
jacocoClasspath = configurations['jacocoAnt']
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"
}
task installGitHooks(type: Copy, group: "development") {
description = "Install git hooks"
from("${project.rootDir}/scripts/hooks") {
include '*'
}
into '.git/hooks'
}
detekt {
reports {
xml {
enabled = false
}
}
config = files("detekt.yml")
input = files("src/")
}
shot {
showOnlyFailingTestsInReports = ciBuild
}
jacoco {
toolVersion = "$jacoco_version"
}
spotbugs {
ignoreFailures = true // should continue checking
effort = "max"
reportLevel = "medium"
}
tasks.withType(SpotBugsTask){task ->
String variantNameCap = task.name.replace("spotbugs", "")
String variantName = variantNameCap.substring(0, 1).toLowerCase() + variantNameCap.substring(1)
dependsOn "compile${variantNameCap}Sources"
excludeFilter = file("${project.rootDir}/spotbugs-filter.xml")
classes = fileTree("$project.buildDir/intermediates/javac/${variantName}/classes/")
reports {
xml.enabled = false
html {
enabled = true
destination = file("$project.buildDir/reports/spotbugs/spotbugs.html")
}
}
}