aboutsummaryrefslogtreecommitdiff
path: root/build.gradle
blob: af619ac7af498f7ca71390a58554616c147fd665 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
apply plugin: 'java'

configurations {
    // similar to 'default', export compile-time dependencies
    host.extendsFrom(hostCompile)
    target.extendsFrom(targetCompile)
}

sourceSets {
    host {
        java {
            srcDirs = ['src/main/java']
        }
    }

    target {
        java {
            srcDirs = ['src/main/java']
            include 'org/**',
                    'junit/extensions/**',
                    // remove these packages since they are in android.test.runner
                    // and proguard complains if they are present
                    // 'junit/runner/**',
                    // 'junit/textui/**',
                    'junit/framework/ComparisonCompactor.java',
                    'junit/framework/JUnit4TestAdapterCache.java',
                    'junit/framework/JUnit4TestAdapter.java',
                    'junit/framework/JUnit4TestCaseFacade.java'
        }
    }
}

task targetJar(type: Jar) {
    from sourceSets.target.output
    dependsOn targetClasses
    baseName "junit4"
    classifier "target"
}

task hostJar(type: Jar) {
    from sourceSets.host.output
    dependsOn hostClasses
    baseName "junit4"
    classifier "host"
}

artifacts {
    host hostJar
    target targetJar
}

if (project.hasProperty("usePrebuilts") && project.usePrebuilts == "true") {
    repositories {
        maven { url '../../prebuilts/tools/common/m2/repository' }
    }

    dependencies {
        targetCompile getAndroidPrebuilt('4')
        targetCompile 'org.hamcrest:hamcrest-core:1.1'

        hostCompile 'org.hamcrest:hamcrest-core:1.1'
    }
} else {
    dependencies {
        targetCompile getAndroidPrebuilt('4')
        targetCompile project(':hamcrest')

        hostCompile project(':hamcrest')
    }
}