1 /* 2 * Modified from https://gist.github.com/xian/05c4f27da6d4156b9827842217c2cd5c 3 * Reference: http://robolectric.org/blog/2017/03/01/hermetic-builds/ 4 * 5 * Run this script by `gradle -b update.gradle` 6 */ 7 8 defaultTasks 'copySdks' 9 10 def androidSdkVersions = [ 11 '4.1.2_r1-robolectric-0', 12 '4.1.2_r1-robolectric-r1', 13 '4.2.2_r1.2-robolectric-0', 14 '4.2.2_r1.2-robolectric-r1', 15 '4.3_r2-robolectric-0', 16 '4.3_r2-robolectric-r1', 17 '4.4_r1-robolectric-1', 18 '4.4_r1-robolectric-r2', 19 '5.0.0_r2-robolectric-1', 20 '5.0.2_r3-robolectric-r0', 21 '5.1.1_r9-robolectric-1', 22 '5.1.1_r9-robolectric-r2', 23 '6.0.0_r1-robolectric-0', 24 '6.0.1_r3-robolectric-0', 25 '6.0.1_r3-robolectric-r1', 26 '7.0.0_r1-robolectric-0', 27 '7.0.0_r1-robolectric-r1', 28 '7.1.0_r7-robolectric-0', 29 '7.1.0_r7-robolectric-r1', 30 'o-preview-4-robolectric-0', 31 '8.0.0_r4-robolectric-0', 32 '8.0.0_r4-robolectric-r1', 33 '8.1.0-robolectric-r4458339', 34 ] 35 36 def buildDir = System.getProperty("user.dir") 37 38 apply plugin: 'java' 39 40 repositories { 41 mavenCentral() 42 } 43 44 configurations { 45 sandbox 46 } 47 48 def allSdkConfigurations = [] 49 50 androidSdkVersions.forEach { version -> 51 allSdkConfigurations << configurations.create(version) 52 dependencies.add(version, "org.robolectric:android-all:${version}") 53 dependencies.add('sandbox', "org.robolectric:android-all:${version}") 54 } 55 56 task copySdks(type: Copy) { 57 into "$buildDir" 58 from allSdkConfigurations 59 60 doLast { 61 // robolectric-deps file is not used in Make build, so we don't need to generate it 62 // def f = new File("$buildDir/robolectric-deps.properties") 63 // f.delete() 64 65 // f << "# Place this file in your test resources dir (e.g. src/test/resources).\n" 66 // f << "# Paths below should be absolute, or relative to this file.\n" 67 // f << "#\n" 68 69 allSdkConfigurations.forEach { config -> 70 config.allDependencies.forEach { dep -> 71 def files = new ArrayList(config.files) 72 if (files.size != 1) { 73 throw new RuntimeException("huh, more than one file in ${dep}? ${files}") 74 } 75 // def file = files[0] 76 // f << "${dep.group}\\:${dep.name}\\:${dep.version}=path/to/${file.name}\n" 77 } 78 } 79 } 80 } 81