0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 12:02:16 +02:00
Anki-Android/AnkiDroid/build.gradle
Mike Hardy 7acc79e14e Coverage reports / Codacy integration (#4919)
* Add jacoco dependency, bump gradle plugin dependency
* Implement integrated coverage report for debug builds
* Report coverage in Travis, aggregate all API reports in Codacy

Fixes #4914
Fixes #3056
Fixes #4588
Fixes #2254
2018-09-03 17:02:27 +09:00

152 lines
5.7 KiB
Groovy

apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play'
apply plugin: 'jacoco'
def homePath = System.properties['user.home']
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.ichi2.anki"
minSdkVersion 15
targetSdkVersion 25
testApplicationId "com.ichi2.anki.tests"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
lintOptions {
abortOnError false
disable 'TypographyEllipsis'
}
signingConfigs {
release {
storeFile file("${homePath}/src/android-keystore")
keyAlias "nrkeystorealias"
storePassword System.getenv("KSTOREPWD")
keyPassword System.getenv("KEYPWD")
}
}
buildTypes {
debug {
debuggable true
// Check Crash Reports page on developer wiki for info on ACRA testing
buildConfigField "String", "ACRA_URL", '"https://918f7f55-f238-436c-b34f-c8b5f1331fe5-bluemix.cloudant.com/acra-ankidroid/_design/acra-storage/_update/report"'
testCoverageEnabled true
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
buildConfigField "String", "ACRA_URL", '"https://ankidroid.org/acra/report"'
}
}
useLibrary 'org.apache.http.legacy'
testOptions {
// we should use orchestrator, but app data shared on /sdcard makes it unstable
//execution 'ANDROID_TEST_ORCHESTRATOR'
animationsDisabled true
unitTests {
includeAndroidResources = true
}
}
dexOptions {
// Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
preDexLibraries = preDexEnabled && !travisBuild
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
play {
serviceAccountEmail = '294046724212-r3bef6kl46pb9gk0h1pl5rcjmpfrdpjl@developer.gserviceaccount.com'
pk12File = file("${homePath}/src/583631bdd16d.p12")
track = 'alpha'
}
jacoco {
toolVersion = "$jacocoVersion"
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
// Our merge report task
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
reports {
xml.enabled = true
xml.destination = "${buildDir}/reports/jacoco/report.xml"
html.enabled = true
html.destination = "${buildDir}/reports/jacoco"
}
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
def debugTree = fileTree(dir: "$project.buildDir/intermediates/javac/debug/compileDebugJavaWithJavac/classes", excludes: fileFilter)
def mainSrc = "$project.projectDir/src/main/java"
sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec',
'outputs/code-coverage/connected/**/*.ec'
])
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
// Note: the design support library can be quite buggy, so test everything thoroughly before updating it
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:customtabs:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'io.requery:sqlite-android:3.24.0'
implementation 'android.arch.persistence:db:1.1.1'
implementation('com.afollestad.material-dialogs:core:0.8.6.2@aar') {
//exclude group: 'com.android.support' // uncomment to force our local support lib version
transitive = true
}
implementation 'com.getbase:floatingactionbutton:1.10.1'
// ACRA pulls in support 27.0.2, we can remove the excludes if we upgrade
implementation('ch.acra:acra-http:5.1.3') {
exclude group: 'com.android.support'
}
implementation('ch.acra:acra-dialog:5.1.3') {
exclude group: 'com.android.support'
}
implementation('ch.acra:acra-toast:5.1.3') {
exclude group: 'com.android.support'
}
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'org.jsoup:jsoup:1.11.3'
api project(":api")
testImplementation 'org.junit.vintage:junit-vintage-engine:5.2.0'
testImplementation 'org.mockito:mockito-core:2.21.0'
testImplementation 'org.powermock:powermock-core:2.0.0-beta.5'
testImplementation 'org.powermock:powermock-module-junit4:2.0.0-beta.5'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.0-beta.5'
testImplementation 'org.hamcrest:hamcrest-all:1.3'
testImplementation 'net.lachlanmckee:timber-junit-rule:1.0.1'
// 3 excludes, to avoid dependency resolve clash between our 26.0.1 and 27.1.1
// This will be solved if we move all the android stuff to 27.1.1
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation('com.android.support.test:runner:1.0.2') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation('com.android.support.test:rules:1.0.2') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestUtil 'com.android.support.test:orchestrator:1.0.2'
}