提交 e1a4a1a0 编写于 作者: B Blankj

see 07/08 log

上级 47d2b34a
......@@ -53,6 +53,7 @@ dependencies {
def leakCanary = "com.squareup.leakcanary:leakcanary-android-no-op:$LEAKCANARY_VERSION"
compile project(':utilcode')
compile project(':subutil')
compile "com.android.support:appcompat-v7:$SUPPORT_VERSION"
compile "com.android.support:support-v4:$SUPPORT_VERSION"
compile "com.android.support:design:$SUPPORT_VERSION"
......
include ':app', ':utilcode'
include ':app', ':utilcode', ':subutil'
apply plugin: 'com.android.library'
apply plugin: 'jacoco'
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
reports {
xml.enabled = true
html.enabled = true
}
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/java"
sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = fileTree(dir: "$buildDir", includes: [
"jacoco/testDebugUnitTest.exec",
"outputs/code-coverage/connected/*coverage.ec"
])
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 14
versionCode 41
versionName "1.7.1"
}
buildTypes {
debug {
testCoverageEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
tasks.matching { it instanceof Test }.all {
testLogging.events = ["failed", "passed", "skipped"]
}
dependencies {
final SUPPORT_VERSION = '25.3.1'
final JUNIT_VERSION = '4.12'
final TRUTH_VERSION = '0.31'
final ROBOLECTRIC_VERSION = '3.1.2'
provided "com.android.support:appcompat-v7:$SUPPORT_VERSION"
provided "com.android.support:support-v4:$SUPPORT_VERSION"
provided "com.android.support:design:$SUPPORT_VERSION"
testCompile "junit:junit:$JUNIT_VERSION"
testCompile "org.robolectric:robolectric:$ROBOLECTRIC_VERSION"
}
//apply from: "https://raw.githubusercontent.com/xiaopansky/android-library-publish-to-jcenter/master/bintrayUpload.gradle"
//gradlew bintrayUpload
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/Blankj/Library/Android/android_sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
<manifest package="com.blankj.subutil"/>
package com.blankj.utilcode.util;
package com.blankj.subutil.util;
import android.support.v4.util.SimpleArrayMap;
......
package com.blankj.utilcode.util;
package com.blankj.subutil.util;
import android.support.annotation.IntDef;
......
package com.blankj.subutil.util;
import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.NonNull;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 16/12/08
* desc : Utils初始化相关
* </pre>
*/
public final class Utils {
@SuppressLint("StaticFieldLeak")
private static Context context;
private Utils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/**
* 初始化工具类
*
* @param context 上下文
*/
public static void init(@NonNull final Context context) {
Utils.context = context.getApplicationContext();
}
/**
* 获取ApplicationContext
*
* @return ApplicationContext
*/
public static Context getContext() {
if (context != null) return context;
throw new NullPointerException("u should init first");
}
}
<resources>
<string name="app_name">subutil</string>
</resources>
package com.blankj.subutil;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册