You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ky...@apache.org on 2017/09/07 08:18:20 UTC
[03/14] incubator-weex git commit: * [android] add jacoco test code
coverage data
* [android] add jacoco test code coverage data
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/aef6abac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/aef6abac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/aef6abac
Branch: refs/heads/0.16-dev
Commit: aef6abac446ec0b46877e245527fcf16736f65ef
Parents: 18d5dc5
Author: atomtong <to...@qq.com>
Authored: Thu Aug 31 15:47:34 2017 +0800
Committer: atomtong <to...@qq.com>
Committed: Thu Aug 31 15:47:34 2017 +0800
----------------------------------------------------------------------
android/build.gradle | 25 ++-
android/playground/app/build.gradle | 50 +++++-
android/playground/app/jacoco.gradle | 154 +++++++++++++++++++
.../java/com/alibaba/weex/IndexActivity.java | 6 +-
.../java/com/alibaba/weex/WXPageActivity.java | 2 +-
5 files changed, 224 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/aef6abac/android/build.gradle
----------------------------------------------------------------------
diff --git a/android/build.gradle b/android/build.gradle
index 04cbb67..b1297a9 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -2,10 +2,14 @@
buildscript {
repositories {
mavenCentral()
+ maven {
+ url "http://mvnrepo.alibaba-inc.com/mvn/repository"
+ }
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.3'
+ classpath 'com.android.tools.build:gradle:2.3.0'
+ classpath 'com.taobao.android.gradle:mtl-plugin:2.3.1.jacoco-SNAPSHOT'
}
}
@@ -13,19 +17,30 @@ plugins {
id "de.undercouch.download" version "3.2.0"
}
-repositories {
+allprojects {
+ repositories {
mavenCentral()
+ maven {
+ url "http://mvnrepo.alibaba-inc.com/mvn/repository"
+ }
jcenter()
+ }
}
subprojects {
repositories {
mavenCentral()
+ maven {
+ url "http://mvnrepo.alibaba-inc.com/mvn/repository"
+ }
jcenter()
}
buildscript {
repositories {
mavenCentral()
+ maven {
+ url "http://mvnrepo.alibaba-inc.com/mvn/repository"
+ }
jcenter()
}
dependencies {
@@ -35,9 +50,9 @@ subprojects {
ext {
compileSdkVersion=25
buildToolsVersion="25.0.3"
- minSdkVersion=14
- appMinSdkVersion=15
- targetSdkVersion=25
+ minSdkVersion=21
+ appMinSdkVersion=21
+ targetSdkVersion=21
supportLibVersion="25.3.1"
fastjsonLibVersion="1.1.46.android"
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/aef6abac/android/playground/app/build.gradle
----------------------------------------------------------------------
diff --git a/android/playground/app/build.gradle b/android/playground/app/build.gradle
index 1da00d1..f098434 100755
--- a/android/playground/app/build.gradle
+++ b/android/playground/app/build.gradle
@@ -1,6 +1,5 @@
apply plugin: 'com.android.application'
-apply from: '../../jacoco.gradle'
-
+apply plugin: 'com.taobao.android.jacoco'
android {
compileSdkVersion project.compileSdkVersion
@@ -44,9 +43,9 @@ android {
main {
jniLibs.srcDir(['libs'])
java {
- srcDirs = ["src/main/java", "src/main/java_zxing"];
+// srcDirs = ["src/main/java", "src/main/java_zxing"];
+ srcDirs = ['src/main/java']
}
- resources.includes = [ '**/jacoco-agent.properties' ]
}
}
lintOptions {
@@ -109,4 +108,47 @@ dependencies {
compile 'com.taobao.android.weex_inspection:urlconnection_interceptor:1.0.0'
compile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'
compile 'com.taobao.android:weex_inspector:0.11.0'
+}
+
+
+def coverageSourceDirs = ['../../../android/sdk/src/main/java']
+task jacocoTestReport(type: JacocoReport) {
+ group = "Reporting"
+ description = "Generate Jacoco coverage reports after running tests."
+ reports {
+ xml.enabled = true
+ html.enabled = true
+ }
+ classDirectories = fileTree(//"enter code here"
+ dir: '../../../android/sdk/build/intermediates/classes/debug',
+ excludes: ['**/R*.class',
+ '**/*$InjectAdapter.class',
+ '**/*$ViewInjector*.class',
+ '**/*$BuildConfig.*',
+ '**/R.class',
+ '**/*$ViewInjector*.*',
+ '**/*$ViewBinder*.*',
+ '**/*MembersInjector*.*',
+ '**/BuildConfig.*',
+ '**/Manifest*.*',
+ '**/*$Lambda$*.class',
+ '**/*Factory*.class',
+ '**/*$Builder*',
+ '**/*DaggerApplicationComponent*.class',
+ '**/api'
+ ])
+ sourceDirectories = files(coverageSourceDirs)
+ File configFile = file('../../../android/sdk/build/intermediates/classes/debug')
+
+ configFile = file(configFile.absolutePath)
+ println configFile.path
+
+ executionData = files("$buildDir/outputs/coverage.ec")
+ doFirst {
+ new File("../../../android/sdk/build/intermediates/classes/").eachFileRecurse { file ->
+ if (file.name.contains('$$')) {
+ file.renameTo(file.path.replace('$$', '$'))
+ }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/aef6abac/android/playground/app/jacoco.gradle
----------------------------------------------------------------------
diff --git a/android/playground/app/jacoco.gradle b/android/playground/app/jacoco.gradle
new file mode 100644
index 0000000..f098434
--- /dev/null
+++ b/android/playground/app/jacoco.gradle
@@ -0,0 +1,154 @@
+apply plugin: 'com.android.application'
+apply plugin: 'com.taobao.android.jacoco'
+
+android {
+ compileSdkVersion project.compileSdkVersion
+ buildToolsVersion project.buildToolsVersion
+
+ defaultConfig {
+ applicationId "com.alibaba.weex"
+ minSdkVersion project.appMinSdkVersion
+ targetSdkVersion project.targetSdkVersion
+ versionCode 13
+ versionName "0.5.2.5"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ ndk{
+ abiFilters "x86"
+ abiFilters "armeabi"
+ }
+ }
+ applicationVariants.all { variant ->
+ variant.outputs.each { output ->
+ def outputFile = output.outputFile
+ if (outputFile != null && outputFile.name.equals('app-debug.apk')) {
+ def fileName = outputFile.name.replace("app-debug.apk", "playground.apk")
+ output.outputFile = new File(outputFile.parent, fileName)
+ }
+ }
+ }
+ signingConfigs {
+ debug {
+ storeFile file("tools/weex.jks")
+ storePassword "123456"
+ keyAlias "weex"
+ keyPassword "123456"
+ }
+ }
+ buildTypes {
+ debug {
+ testCoverageEnabled true
+ }
+ }
+ sourceSets {
+ main {
+ jniLibs.srcDir(['libs'])
+ java {
+// srcDirs = ["src/main/java", "src/main/java_zxing"];
+ srcDirs = ['src/main/java']
+ }
+ }
+ }
+ lintOptions {
+ abortOnError false
+ }
+
+ packagingOptions {
+ exclude 'LICENSE.txt'
+ }
+ testOptions {
+ reportDir = "$project.buildDir/test/report"
+ }
+ dexOptions {
+ preDexLibraries false
+ }
+}
+
+
+dependencies {
+ compile fileTree(include: ['*.jar'], dir: 'libs')
+ androidTestCompile "com.android.support:support-annotations:${project.supportLibVersion}"
+ androidTestCompile 'junit:junit:4.12'
+ androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
+ androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ exclude group: 'com.android.support', module: 'support-v4'
+ exclude group: 'com.android.support', module: 'design'
+ exclude group: 'com.android.support', module: 'appcompat-v7'
+ exclude group: 'com.android.support', module: 'recyclerview-v7'
+ })
+ androidTestCompile 'com.android.support.test:runner:0.5'
+ androidTestCompile 'com.squareup.picasso:picasso:2.5.2'
+ androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
+ androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
+ /*source dependency*/
+ compile project(':weex_sdk')
+ debugCompile project(':weex_debug')
+
+ //https://github.com/weexteam/weex-analyzer-android
+ //Weex-Analyzer provides several convenient tools such as Memory Monitor
+ // to optimize your application. It's not available by default,you can
+ // set WXAnalyzerDelegate#DEBUG==true to enable it
+ debugCompile 'com.taobao.android:weex_analyzer:0.1.0.5'
+
+ compile project(':commons')
+ compile 'com.taobao.android:dexposed:0.1.8'
+ compile 'com.loopj.android:android-async-http:1.4.9@aar'
+ compile 'com.facebook.fresco:fresco:0.12.0+'
+ compile 'com.facebook.fresco:animated-gif:0.12.0'
+
+ compile 'com.squareup.okhttp:okhttp:2.3.0'
+ compile 'com.squareup.okhttp:okhttp-ws:2.3.0'
+ compile 'com.squareup.okio:okio:1.0.1'
+ compile "com.alibaba:fastjson:${project.fastjsonLibVersion}"
+ compile "com.android.support:support-v4:${project.supportLibVersion}"
+ compile "com.android.support:appcompat-v7:${project.supportLibVersion}"
+ compile "com.android.support:design:${project.supportLibVersion}"
+ compile "com.android.support:support-annotations:${project.supportLibVersion}"
+ compile 'com.jakewharton.scalpel:scalpel:1.1.2'
+ compile 'com.taobao.android.weex_inspection:urlconnection_interceptor:1.0.0'
+ compile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'
+ compile 'com.taobao.android:weex_inspector:0.11.0'
+}
+
+
+def coverageSourceDirs = ['../../../android/sdk/src/main/java']
+task jacocoTestReport(type: JacocoReport) {
+ group = "Reporting"
+ description = "Generate Jacoco coverage reports after running tests."
+ reports {
+ xml.enabled = true
+ html.enabled = true
+ }
+ classDirectories = fileTree(//"enter code here"
+ dir: '../../../android/sdk/build/intermediates/classes/debug',
+ excludes: ['**/R*.class',
+ '**/*$InjectAdapter.class',
+ '**/*$ViewInjector*.class',
+ '**/*$BuildConfig.*',
+ '**/R.class',
+ '**/*$ViewInjector*.*',
+ '**/*$ViewBinder*.*',
+ '**/*MembersInjector*.*',
+ '**/BuildConfig.*',
+ '**/Manifest*.*',
+ '**/*$Lambda$*.class',
+ '**/*Factory*.class',
+ '**/*$Builder*',
+ '**/*DaggerApplicationComponent*.class',
+ '**/api'
+ ])
+ sourceDirectories = files(coverageSourceDirs)
+ File configFile = file('../../../android/sdk/build/intermediates/classes/debug')
+
+ configFile = file(configFile.absolutePath)
+ println configFile.path
+
+ executionData = files("$buildDir/outputs/coverage.ec")
+ doFirst {
+ new File("../../../android/sdk/build/intermediates/classes/").eachFileRecurse { file ->
+ if (file.name.contains('$$')) {
+ file.renameTo(file.path.replace('$$', '$'))
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/aef6abac/android/playground/app/src/main/java/com/alibaba/weex/IndexActivity.java
----------------------------------------------------------------------
diff --git a/android/playground/app/src/main/java/com/alibaba/weex/IndexActivity.java b/android/playground/app/src/main/java/com/alibaba/weex/IndexActivity.java
index 866733a..ab26512 100644
--- a/android/playground/app/src/main/java/com/alibaba/weex/IndexActivity.java
+++ b/android/playground/app/src/main/java/com/alibaba/weex/IndexActivity.java
@@ -40,7 +40,7 @@ import android.widget.TextView;
import android.widget.Toast;
import com.alibaba.weex.commons.AbstractWeexActivity;
-import com.google.zxing.client.android.CaptureActivity;
+//import com.google.zxing.client.android.CaptureActivity;
import com.taobao.weex.WXRenderErrorCode;
import com.taobao.weex.WXSDKEngine;
import com.taobao.weex.WXSDKInstance;
@@ -145,7 +145,7 @@ public class IndexActivity extends AbstractWeexActivity {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, CAMERA_PERMISSION_REQUEST_CODE);
}
} else {
- startActivity(new Intent(this, CaptureActivity.class));
+// startActivity(new Intent(this, CaptureActivity.class));
}
break;
default:
@@ -159,7 +159,7 @@ public class IndexActivity extends AbstractWeexActivity {
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == CAMERA_PERMISSION_REQUEST_CODE && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- startActivity(new Intent(this, CaptureActivity.class));
+// startActivity(new Intent(this, CaptureActivity.class));
} else if (requestCode == WRITE_EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
} else {
Toast.makeText(this, "request camara permission fail!", Toast.LENGTH_SHORT).show();
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/aef6abac/android/playground/app/src/main/java/com/alibaba/weex/WXPageActivity.java
----------------------------------------------------------------------
diff --git a/android/playground/app/src/main/java/com/alibaba/weex/WXPageActivity.java b/android/playground/app/src/main/java/com/alibaba/weex/WXPageActivity.java
index dd303b5..e1a3b83 100644
--- a/android/playground/app/src/main/java/com/alibaba/weex/WXPageActivity.java
+++ b/android/playground/app/src/main/java/com/alibaba/weex/WXPageActivity.java
@@ -321,7 +321,7 @@ public class WXPageActivity extends WXBaseActivity implements IWXRenderListener,
protected void onDestroy() {
super.onDestroy();
//jacoco code coverage
- JacocoCodeCoverage.dumpCodeCoverageByJacoco(getApplicationContext());
+// JacocoCodeCoverage.dumpCodeCoverageByJacoco(getApplicationContext());
if (mInstance != null) {
mInstance.onActivityDestroy();