apply plugin: 'com.android.application' apply plugin: 'com.github.triplet.play' apply plugin: 'jacoco' repositories { google() jcenter() } def homePath = System.properties['user.home'] android { compileSdkVersion 28 defaultConfig { applicationId "com.ichi2.anki" minSdkVersion 15 targetSdkVersion 28 testApplicationId "com.ichi2.anki.tests" vectorDrawables.useSupportLibrary = true testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' // This enables long timeouts required on slow ARM emulators, e.g. Travis adbOptions { timeOutInMs 10 * 60 * 1000 // 10 minutes } } 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 } packagingOptions { exclude 'META-INF/DEPENDENCIES' } testOptions.unitTests.all { testLogging { events "failed", "skipped" showStackTraces = true exceptionFormat = "full" } maxParallelForks = gradleTestMaxParallelForks } } play { serviceAccountEmail = '294046724212-r3bef6kl46pb9gk0h1pl5rcjmpfrdpjl@developer.gserviceaccount.com' pk12File = file("${homePath}/src/583631bdd16d.p12") track = 'alpha' } // Deprecation is an error. Use @SuppressWarnings("deprecation") and justify in the PR if you must tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:deprecation" << "-Xmaxwarns" << "1000" << "-Werror" // https://guides.gradle.org/performance/#compiling_java // 1- fork improves things over time with repeated builds, doesn't harm CI single builds options.fork = true // 2- incremental will be the default in the future and can help now options.incremental = true } tasks.withType(Test) { jacoco.includeNoLocationClasses = true } // Our merge report task task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) { reports { xml.enabled = true } 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' ]) } // A unit-test only report task task jacocoUnitTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) { reports { xml.enabled = true } 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' ]) } dependencies { compileOnly "com.google.auto.service:auto-service:1.0-rc4" annotationProcessor "com.google.auto.service:auto-service:1.0-rc4" implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.0.2' // Note: the design support library can be quite buggy, so test everything thoroughly before updating it implementation 'com.google.android.material:material:1.0.0' implementation 'androidx.browser:browser:1.0.0' implementation 'androidx.exifinterface:exifinterface:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.0.0' implementation 'io.requery:sqlite-android:3.25.2' implementation 'androidx.sqlite:sqlite:2.0.0' implementation 'android.arch.persistence:db-framework:1.1.1' implementation 'com.afollestad.material-dialogs:core:0.9.6.0' implementation 'com.getbase:floatingactionbutton:1.10.1' implementation 'androidx.annotation:annotation:1.0.0' implementation 'org.bitbucket.cowwoc:diff-match-patch:1.1' // May need a resolution strategy for support libs to our versions implementation'ch.acra:acra-http:5.2.1' implementation'ch.acra:acra-dialog:5.2.1' implementation'ch.acra:acra-toast:5.2.1' implementation'ch.acra:acra-limiter:5.2.1' implementation 'net.mikehardy:google-analytics-java:2.0.4' implementation 'com.squareup.okhttp3:okhttp:3.12.0' implementation 'com.arcao:slf4j-timber:3.1' 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.3.1' testImplementation 'org.mockito:mockito-core:2.23.0' testImplementation 'org.powermock:powermock-core:2.0.0-RC.4' testImplementation 'org.powermock:powermock-module-junit4:2.0.0-RC.4' testImplementation 'org.powermock:powermock-api-mockito2:2.0.0-RC.4' testImplementation 'org.hamcrest:hamcrest-all:1.3' testImplementation 'net.lachlanmckee:timber-junit-rule:1.0.1' testImplementation 'androidx.test:core:1.0.0' testImplementation "org.robolectric:robolectric:4.0.2" // May need a resolution strategy for support libs to our versions androidTestImplementation 'com.azimolabs.conditionwatcher:conditionwatcher:0.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0' androidTestImplementation 'androidx.test.ext:junit:1.0.0' androidTestImplementation 'androidx.test:runner:1.1.0' androidTestImplementation 'androidx.test:rules:1.1.0' androidTestUtil 'androidx.test:orchestrator:1.1.0' }