nextcloud-android/build.gradle

315 lines
11 KiB
Groovy
Raw Normal View History

// 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 {
repositories {
google()
2016-08-16 16:04:43 +03:00
jcenter()
2017-02-22 01:56:13 +03:00
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
2018-08-22 18:42:15 +03:00
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath('com.dicedmelon.gradle:jacoco-android:0.1.3')
}
}
apply plugin: 'com.android.application'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'findbugs'
apply plugin: 'jacoco-android'
2017-03-06 16:16:31 +03:00
configurations.all {
2018-09-10 11:37:28 +03:00
exclude group: 'com.google.firebase', module: 'firebase-core'
2017-03-06 16:16:31 +03:00
// check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
ext {
supportLibraryVersion = '28.0.0'
jacocoVersion = "0.8.2"
2016-08-16 18:22:22 +03:00
travisBuild = System.getenv("TRAVIS") == "true"
// allows for -Dpre-dex=false to be set
preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
}
repositories {
google()
2016-08-16 16:04:43 +03:00
jcenter()
maven { url "https://jitpack.io" }
2017-11-28 17:01:14 +03:00
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
flatDir {
dirs 'libs'
}
}
// semantic versioning for version code
def versionMajor = 3
2018-09-04 16:57:36 +03:00
def versionMinor = 4
def versionPatch = 0
def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
def taskRequest = getGradle().getStartParameter().getTaskRequests().toString()
if (taskRequest.contains("Gplay") || taskRequest.contains("findbugs") || taskRequest.contains("lint")) {
apply from: 'gplay.gradle'
}
android {
lintOptions {
abortOnError false
htmlReport true
htmlOutput file("$project.buildDir/reports/lint/lint.html")
disable 'MissingTranslation'
}
2017-02-22 02:46:47 +03:00
dexOptions {
javaMaxHeapSize "4g"
}
2018-09-24 09:42:19 +03:00
compileSdkVersion 28
2015-11-28 13:26:58 +03:00
2016-05-05 09:46:47 +03:00
defaultConfig {
2017-12-21 11:47:10 +03:00
minSdkVersion 14
2018-09-24 09:42:19 +03:00
targetSdkVersion 28
2017-12-21 11:47:10 +03:00
2016-05-05 09:46:47 +03:00
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// arguments to be passed to functional tests
testInstrumentationRunnerArgument "TEST_USER", "\"$System.env.OCTEST_APP_USERNAME\""
testInstrumentationRunnerArgument "TEST_PASSWORD", "\"$System.env.OCTEST_APP_PASSWORD\""
testInstrumentationRunnerArgument "TEST_SERVER_URL", "\"$System.env.OCTEST_SERVER_BASE_URL\""
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 true
}
}
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"
2018-12-08 02:34:41 +03:00
versionCode 20181208
versionName "20181208"
2017-04-13 10:14:19 +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
2016-08-16 18:22:22 +03:00
dexOptions {
// Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
preDexLibraries = preDexEnabled && !travisBuild
}
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
task checkstyle(type: 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()
}
task pmd(type: Pmd) {
ruleSetFiles = files("${project.rootDir}/pmd-ruleset.xml")
ignoreFailures = false
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")
}
}
}
task findbugs(type: FindBugs) {
ignoreFailures = false
effort = "max"
reportLevel = "medium"
classes = fileTree("$project.buildDir/intermediates/javac/gplayDebug/compileGplayDebugJavaWithJavac/classes/")
excludeFilter = file("${project.rootDir}/findbugs-filter.xml")
source = fileTree('src/main/java')
pluginClasspath = project.configurations.findbugsPlugins
classpath = files()
include '**/*.java'
exclude '**/gen/**'
reports {
xml.enabled = false
html.enabled = true
html {
destination = file("$project.buildDir/reports/findbugs/findbugs.html")
}
}
}
check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
2016-06-24 01:18:45 +03:00
}
dependencies {
// dependencies for app building
2018-04-03 19:22:38 +03:00
implementation 'com.android.support:multidex:1.0.3'
2017-12-15 13:36:55 +03:00
// implementation project('nextcloud-android-library')
2018-12-10 11:48:45 +03:00
genericImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
gplayImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "com.android.support:support-v4:${supportLibraryVersion}"
implementation "com.android.support:design:${supportLibraryVersion}"
implementation 'com.jakewharton:disklrucache:2.0.2'
implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
implementation "com.android.support:cardview-v7:${supportLibraryVersion}"
implementation "com.android.support:exifinterface:${supportLibraryVersion}"
implementation 'com.github.albfernandez:juniversalchardet:2.0.0' // need this version for Android <7
implementation 'com.google.code.findbugs:annotations:2.0.1'
implementation 'commons-io:commons-io:2.6'
implementation 'com.github.evernote:android-job:v1.2.5'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
2018-09-05 18:56:31 +03:00
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.4'
implementation 'org.lukhnos:nnio:0.2'
implementation 'com.madgag.spongycastle:pkix:1.54.0.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.afollestad:sectioned-recyclerview:0.5.0'
implementation 'com.github.chrisbanes:PhotoView:2.1.4'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15'
2017-08-23 16:52:14 +03:00
implementation 'org.parceler:parceler-api:1.1.12'
annotationProcessor 'org.parceler:parceler:1.1.11'
implementation('com.github.bumptech.glide:glide:3.7.0') {
exclude group: "com.android.support"
}
2018-08-22 18:42:15 +03:00
implementation 'com.caverock:androidsvg:1.3'
implementation "com.android.support:support-annotations:${supportLibraryVersion}"
implementation 'com.google.code.gson:gson:2.8.5'
// dependencies for local unit tests
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.4'
// dependencies for instrumented tests
// JUnit4 Rules
androidTestImplementation 'com.android.support.test:rules:1.0.2'
// Android JUnit Runner
androidTestImplementation 'com.android.support.test:runner:1.0.2'
// Espresso core
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
// UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
2018-01-18 23:37:55 +03:00
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
//androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
implementation 'org.jetbrains:annotations:16.0.3'
2017-09-28 14:53:37 +03:00
compileOnly "org.projectlombok:lombok:1.18.4"
annotationProcessor "org.projectlombok:lombok:1.18.4"
androidTestImplementation 'tools.fastlane:screengrab:1.2.0'
2018-09-05 19:02:53 +03:00
findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.8.0'
2018-09-05 19:03:36 +03:00
findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.3'
// 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}"
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
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"
}
}
task combinedTestReport(type: JacocoReport) {
reports {
xml.enabled = true
html.enabled = true
}
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/gplay/debug", excludes: fileFilter)
def mainSrc = "$project.projectDir/src/main/java"
sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = fileTree(dir: project.buildDir, includes: [
'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
])
}