1 apply plugin: 'java' 2 3 configurations { 4 // similar to 'default', export compile-time dependencies 5 host.extendsFrom(hostCompile) 6 target.extendsFrom(targetCompile) 7 } 8 9 sourceSets { 10 host { 11 java { 12 srcDirs = ['src'] 13 } 14 } 15 16 target { 17 java { 18 srcDirs = ['src'] 19 include 'org/**', 20 'junit/extensions/**', 21 // remove these packages since they are in android.test.runner 22 // and proguard complains if they are present 23 // 'junit/runner/**', 24 // 'junit/textui/**', 25 'junit/framework/ComparisonCompactor.java', 26 'junit/framework/JUnit4TestAdapterCache.java', 27 'junit/framework/JUnit4TestAdapter.java', 28 'junit/framework/JUnit4TestCaseFacade.java' 29 } 30 } 31 } 32 33 dependencies { 34 targetCompile getAndroidPrebuilt('4') 35 targetCompile project(':hamcrest') 36 37 hostCompile project(':hamcrest') 38 } 39 40 task targetJar(type: Jar) { 41 from sourceSets.target.output 42 dependsOn targetClasses 43 baseName "junit4" 44 classifier "target" 45 } 46 47 task hostJar(type: Jar) { 48 from sourceSets.host.output 49 dependsOn hostClasses 50 baseName "junit4" 51 classifier "host" 52 } 53 54 artifacts { 55 host hostJar 56 target targetJar 57 } 58