diff options
author | Nick Korostelev <nkorsote@google.com> | 2014-08-26 18:58:05 -0700 |
---|---|---|
committer | Nick Korostelev <nkorsote@google.com> | 2014-08-26 18:58:05 -0700 |
commit | 922c401ed1b7b2b745ef3f7ffc729898c2a7e03b (patch) | |
tree | e99fcfabb585bf89fc27e9a97145d9ae37557298 | |
parent | 148bb9297a696d586e003e85832ef4dc37ebce68 (diff) | |
download | junit-922c401ed1b7b2b745ef3f7ffc729898c2a7e03b.tar.gz |
more graceful way to build Junit with dependencies from prebuilts
Change-Id: I127ddf1df97c14855196c18ccb7a69fbdc237c7d
-rw-r--r-- | build-common.gradle | 50 | ||||
-rw-r--r-- | build-prebuilts.gradle | 12 | ||||
-rw-r--r-- | build.gradle | 72 |
3 files changed, 67 insertions, 67 deletions
diff --git a/build-common.gradle b/build-common.gradle deleted file mode 100644 index dec2903..0000000 --- a/build-common.gradle +++ /dev/null @@ -1,50 +0,0 @@ -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' - } - } -} - -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 -} diff --git a/build-prebuilts.gradle b/build-prebuilts.gradle deleted file mode 100644 index 35af441..0000000 --- a/build-prebuilts.gradle +++ /dev/null @@ -1,12 +0,0 @@ -apply from: "build-common.gradle" - -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' -} diff --git a/build.gradle b/build.gradle index 01e9133..722846c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,70 @@ -apply from: "build-common.gradle" +apply plugin: 'java' -dependencies { - targetCompile getAndroidPrebuilt('4') - targetCompile project(':hamcrest') +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' + } + } +} + +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') + hostCompile project(':hamcrest') + } } |