aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/build.gradle
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/build.gradle')
-rw-r--r--OpenKeychain/build.gradle68
1 files changed, 65 insertions, 3 deletions
diff --git a/OpenKeychain/build.gradle b/OpenKeychain/build.gradle
index a4caa1fe7..3c239d44b 100644
--- a/OpenKeychain/build.gradle
+++ b/OpenKeychain/build.gradle
@@ -1,5 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'witness'
+apply plugin: 'jacoco'
+apply plugin: 'com.github.kt3k.coveralls'
dependencies {
// NOTE: Always use fixed version codes not dynamic ones, e.g. 0.7.3 instead of 0.7.+, see README for more information
@@ -10,8 +12,15 @@ dependencies {
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:recyclerview-v7:22.1.0'
compile 'com.android.support:cardview-v7:22.1.0'
-
- // UI testing libs
+
+ // Unit tests in the local JVM with Robolectric
+ // https://developer.android.com/training/testing/unit-testing/local-unit-tests.html
+ // https://github.com/nenick/AndroidStudioAndRobolectric
+ // http://www.vogella.com/tutorials/Robolectric/article.html
+ testCompile 'junit:junit:4.12'
+ testCompile 'org.robolectric:robolectric:3.0-rc3'
+
+ // UI testing with Espresso
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
@@ -98,7 +107,9 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
-
+ versionCode 32300
+ versionName "3.2.3"
+ applicationId "org.sufficientlysecure.keychain"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
@@ -111,6 +122,26 @@ android {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+
+ // Reference them in the java files with e.g. BuildConfig.ACCOUNT_TYPE.
+ buildConfigField "String", "ACCOUNT_TYPE", "\"org.sufficientlysecure.keychain.account\""
+
+ // Reference them in .xml files.
+ resValue "string", "account_type", "org.sufficientlysecure.keychain.account"
+ }
+
+ debug {
+ applicationIdSuffix ".debug"
+
+ // Reference them in the java files with e.g. BuildConfig.ACCOUNT_TYPE.
+ buildConfigField "String", "ACCOUNT_TYPE", "\"org.sufficientlysecure.keychain.debug.account\""
+
+ // Reference them in .xml files.
+ resValue "string", "account_type", "org.sufficientlysecure.keychain.debug.account"
+
+ // Disabled: only works for androidTest not test!
+ // Enable code coverage (Jacoco)
+ //testCoverageEnabled true
}
}
@@ -163,6 +194,37 @@ android {
}
}
+task jacocoTestReport(type:JacocoReport) {
+ group = "Reporting"
+ description = "Generate Jacoco coverage reports"
+
+ classDirectories = fileTree(
+ dir: "${buildDir}/intermediates/classes/debug",
+ excludes: ['**/R.class',
+ '**/R$*.class',
+ '**/*$ViewInjector*.*',
+ '**/BuildConfig.*',
+ '**/Manifest*.*']
+ )
+
+ sourceDirectories = files("${buildDir.parent}/src/main/java")
+ additionalSourceDirs = files([
+ "${buildDir}/generated/source/buildConfig/debug",
+ "${buildDir}/generated/source/r/debug"
+ ])
+ executionData = files("${buildDir}/jacoco/testDebug.exec")
+
+ reports {
+ xml.enabled = true
+ html.enabled = true
+ }
+}
+
+// Fix for: No report file available: [/home/travis/build/open-keychain/open-keychain/OpenKeychain/build/reports/cobertura/coverage.xml, /home/travis/build/open-keychain/open-keychain/OpenKeychain/build/reports/jacoco/test/jacocoTestReport.xml]
+coveralls {
+ jacocoReportPath 'build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml'
+}
+
// NOTE: This disables Lint!
tasks.whenTaskAdded { task ->
if (task.name.contains('lint')) {