apply plugin: 'java' configurations { // similar to 'default', export compile-time dependencies host.extendsFrom(hostCompile) target.extendsFrom(targetCompile) } sourceSets { host { java { srcDirs = ['src'] } } target { java { srcDirs = ['src'] 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' } } } dependencies { targetCompile getAndroidPrebuilt('4') targetCompile project(':hamcrest') hostCompile project(':hamcrest') } 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 }