build.gradle 3.6 KB
Newer Older
S
Sam Judd 已提交
1
apply plugin: 'com.android.library'
2
apply plugin: 'robolectric'
3
apply plugin: 'maven'
S
Sam Judd 已提交
4
apply plugin: 'findbugs'
S
Sam Judd 已提交
5
apply plugin: 'pmd'
S
Sam Judd 已提交
6 7
apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'
S
Sam Judd 已提交
8

S
Sam Judd 已提交
9 10 11
findbugs {
    toolVersion = "2.0.3"
}
S
Sam Judd 已提交
12 13 14 15 16 17
jacoco {
    toolVersion = "0.7.1.201405082137"
}
coveralls {
    jacocoReportPath = 'build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml'
}
S
Sam Judd 已提交
18 19

dependencies {
E
Emil Arfvidsson 已提交
20
    compile project(':third_party:gif_decoder')
S
Sam Judd 已提交
21
    compile project(':third_party:gif_encoder')
22
    compile project(':third_party:disklrucache')
23
    compile "com.android.support:support-v4:${SUPPORT_V4_VERSION}"
24

S
Sam Judd 已提交
25
    androidTestCompile project(':testutil')
26
    androidTestCompile 'com.google.guava:guava-testlib:18.0'
27
    androidTestCompile "com.android.support:support-v4:${SUPPORT_V4_VERSION}"
S
Sam Judd 已提交
28
    androidTestCompile "com.google.truth:truth:${TRUTH_VERSION}"
29 30 31
    androidTestCompile "junit:junit:${JUNIT_VERSION}"
    androidTestCompile "org.mockito:mockito-all:${MOCKITO_VERSION}"
    androidTestCompile "org.robolectric:robolectric:${ROBOLECTRIC_VERSION}"
32
    // TODO: increase this to 2.0.+ when we compile against Java 7.
33
    androidTestCompile "com.squareup.okhttp:mockwebserver:${MOCKWEBSERVER_VERSION}"
S
Sam Judd 已提交
34 35 36
}

android {
37 38
    compileSdkVersion COMPILE_SDK_VERSION as int
    buildToolsVersion BUILD_TOOLS_VERSION
S
Sam Judd 已提交
39

40
    defaultConfig {
41 42
        minSdkVersion MIN_SDK_VERSION as int
        targetSdkVersion TARGET_SDK_VERSION as int
43

S
Sam Judd 已提交
44
        versionCode = VERSION_CODE as int
S
Sam Judd 已提交
45
        versionName = VERSION_NAME
46
    }
S
Sam Judd 已提交
47 48 49 50 51 52

    buildTypes {
        debug {
            testCoverageEnabled = true
        }
    }
E
Emil Arfvidsson 已提交
53
}
S
Sam Judd 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

afterEvaluate {
    task findbugs(type: FindBugs, dependsOn: assembleDebug) {

        description 'Run findbugs'
        group 'verification'

        classes = fileTree('build/intermediates/classes/debug/')
        source = fileTree('src/main/java')
        classpath = files(project.configurations.compile.asPath)

        effort = 'max'

        excludeFilter = file("findbugs-exclude.xml")

        reports {
            xml.enabled = false
            html.enabled = true
        }
    }
S
Sam Judd 已提交
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

    findbugsTestDebug {
        enabled = false
    }

    check.dependsOn('findbugs')

    task pmd(type: Pmd) {

        description 'Run pmd'
        group 'verification'

        // If ruleSets is not empty, it seems to contain some
        // defaults which override rules in the ruleset file...
        ruleSets = []
        ruleSetFiles = files('pmd-ruleset.xml')
        source = fileTree('src/main/java')

        reports {
            xml.enabled = false
            html.enabled = true
        }
    }

    pmdTestDebug {
        enabled = false
S
Sam Judd 已提交
100
    }
S
Sam Judd 已提交
101 102

    check.dependsOn('pmd')
S
Sam Judd 已提交
103 104 105 106 107 108 109 110 111 112 113

    task jacocoTestReport(type:JacocoReport, dependsOn: testDebug) {
        def coverageSourceDirs = ['src/main/java']
        group = "Reporting"
        description = "Generate Jacoco coverage reports"

        classDirectories = fileTree(
                dir: 'build/intermediates/classes/debug',
                excludes: ['**/R.class',
                           '**/R$*.class',
                           '**/BuildConfig.*',
114 115 116 117
                           '**/Manifest*.*',
                           '**/BitmapRequestBuilder.class',
                           '**/DrawableRequestBuilder.class',
                           '**/GifRequestBuilder.class', ]
S
Sam Judd 已提交
118 119 120 121 122 123 124 125 126 127 128
        )

        additionalSourceDirs = files(coverageSourceDirs)
        sourceDirectories = files(coverageSourceDirs)
        executionData = files('build/jacoco/testDebug.exec')

        reports {
            xml.enabled = true
            html.enabled = true
        }
    }
S
Sam Judd 已提交
129
}