diff options
author | mar-v-in <github@rvin.mooo.com> | 2014-07-31 23:19:01 +0200 |
---|---|---|
committer | mar-v-in <github@rvin.mooo.com> | 2014-07-31 23:19:01 +0200 |
commit | eae7c711a3f588a24ef621a8b82bcd793bcb7e70 (patch) | |
tree | 6c1017380b9234a193cfc6c6460ebfd44923837d /OpenKeychain-Test/build.gradle | |
parent | 0c7eea225b7c04549e92c8c7729bf0e7a04aa5c7 (diff) | |
parent | 50aea621ba4de844cf6eee077d1f5b14d0247f14 (diff) | |
download | open-keychain-eae7c711a3f588a24ef621a8b82bcd793bcb7e70.tar.gz open-keychain-eae7c711a3f588a24ef621a8b82bcd793bcb7e70.tar.bz2 open-keychain-eae7c711a3f588a24ef621a8b82bcd793bcb7e70.zip |
Merge branch 'master' into improve-file-more
Conflicts:
.gitmodules
OpenKeychain/build.gradle
OpenKeychain/src/main/AndroidManifest.xml
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java
Diffstat (limited to 'OpenKeychain-Test/build.gradle')
-rw-r--r-- | OpenKeychain-Test/build.gradle | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/OpenKeychain-Test/build.gradle b/OpenKeychain-Test/build.gradle new file mode 100644 index 000000000..a98a79dc1 --- /dev/null +++ b/OpenKeychain-Test/build.gradle @@ -0,0 +1,118 @@ +buildscript { + repositories { + mavenCentral() + // need this for com.novoda:gradle-android-test-plugin:0.9.9-SNAPSHOT below (0.9.3 in repos doesn't work!) + // run ./install-custom-gradle-test-plugin.sh to pull the thing into the local repository + mavenLocal() + } + + dependencies { + // NOTE: Always use fixed version codes not dynamic ones, e.g. 0.7.3 instead of 0.7.+, see README for more information + classpath 'com.novoda:gradle-android-test-plugin:0.9.9-SNAPSHOT' + } +} + +apply plugin: 'java' +apply plugin: 'android-test' +apply plugin: 'jacoco' + +dependencies { + testCompile 'junit:junit:4.11' + testCompile 'com.google.android:android:4.1.1.4' + testCompile('com.squareup:fest-android:1.0.+') { exclude module: 'support-v4' } + testCompile ('org.robolectric:robolectric:2.3') { + exclude module: 'classworlds' + exclude module: 'maven-artifact' + exclude module: 'maven-artifact-manager' + exclude module: 'maven-error-diagnostics' + exclude module: 'maven-model' + exclude module: 'maven-plugin-registry' + exclude module: 'maven-profile' + exclude module: 'maven-project' + exclude module: 'maven-settings' + exclude module: 'nekohtml' + exclude module: 'plexus-container-default' + exclude module: 'plexus-interpolation' + exclude module: 'plexus-utils' + exclude module: 'support-v4' // crazy but my android studio don't like this dependency and to fix it remove .idea and re import project + exclude module: 'wagon-file' + exclude module: 'wagon-http-lightweight' + exclude module: 'wagon-http-shared' + exclude module: 'wagon-provider-api' + } +} + +android { + projectUnderTest ':OpenKeychain' +} + +jacoco { + toolVersion = "0.7.0.201403182114" +} + +coverageSourceDirs = [ + '../OpenKeychain/src/main/java', + '../OpenKeychain/src/gen', + '../OpenKeychain/build/source/apt/debug', + '../OpenKeychain/build/source/generated/buildConfig/debug', + '../OpenKeychain/build/source/generated/r/debug' + ] + +jacocoTestReport { + reports { + xml.enabled = true + html.destination "${buildDir}/jacocoHtml" + } + // class R is used, but usage will not be covered, so ignore this class from report + classDirectories = fileTree(dir: '../OpenKeychain/build/intermediates/classes/debug/org/sufficientlysecure/keychain', exclude: 'R*.class') + additionalSourceDirs = files(coverageSourceDirs) + executionData = files('build/jacoco/testDebug.exec') +} + +// new workaround to force add custom output dirs for android studio +task addTest { + def file = file(project.name + ".iml") + doLast { + try { + def parsedXml = (new XmlParser()).parse(file) + def node = parsedXml.component[1] + def outputNode = parsedXml.component[1].output[0] + def outputTestNode = parsedXml.component[1].'output-test'[0] + def rewrite = false + + new Node(node, 'sourceFolder', ['url': 'file://$MODULE_DIR$/' + "${it}", 'isTestSource': "true"]) + + if(outputNode == null) { + new Node(node, 'output', ['url': 'file://$MODULE_DIR$/build/resources/testDebug']) + } else { + if(outputNode.attributes['url'] != 'file://$MODULE_DIR$/build/resources/testDebug') { + outputNode.attributes = ['url': 'file://$MODULE_DIR$/build/resources/testDebug'] + rewrite = true + } + } + + if(outputTestNode == null) { + new Node(node, 'output-test', ['url': 'file://$MODULE_DIR$/build/test-classes/debug']) + } else { + if(outputTestNode.attributes['url'] != 'file://$MODULE_DIR$/build/test-classes/debug') { + outputTestNode.attributes = ['url': 'file://$MODULE_DIR$/build/test-classes/debug'] + rewrite = true + } + } + + if(rewrite) { + def writer = new StringWriter() + new XmlNodePrinter(new PrintWriter(writer)).print(parsedXml) + file.text = writer.toString() + } + } catch (FileNotFoundException e) { + // iml not found, common on command line only builds + } + + } +} + +// always do the addtest on prebuild +gradle.projectsEvaluated { + testDebugClasses.dependsOn(addTest) +} |