1class AndroidSdk implements Comparable<AndroidSdk> { 2 static final PREINSTRUMENTED_VERSION = 4 3 4 static final JELLY_BEAN = new AndroidSdk(16, "4.1.2_r1", "r1") 5 static final JELLY_BEAN_MR1 = new AndroidSdk(17, "4.2.2_r1.2", "r1") 6 static final JELLY_BEAN_MR2 = new AndroidSdk(18, "4.3_r2", "r1") 7 static final KITKAT = new AndroidSdk(19, "4.4_r1", "r2") 8 static final LOLLIPOP = new AndroidSdk(21, "5.0.2_r3", "r0") 9 static final LOLLIPOP_MR1 = new AndroidSdk(22, "5.1.1_r9", "r2") 10 static final M = new AndroidSdk(23, "6.0.1_r3", "r1") 11 static final N = new AndroidSdk(24, "7.0.0_r1", "r1") 12 static final N_MR1 = new AndroidSdk(25, "7.1.0_r7", "r1") 13 static final O = new AndroidSdk(26, "8.0.0_r4", "r1") 14 static final O_MR1 = new AndroidSdk(27, "8.1.0", "4611349") 15 static final P = new AndroidSdk(28, "9", "4913185-2"); 16 static final Q = new AndroidSdk(29, "10", "5803371"); 17 static final R = new AndroidSdk(30, "11", "6757853"); 18 static final S = new AndroidSdk(31, "12", "7732740"); 19 static final S_V2 = new AndroidSdk(32, "12.1", "8229987"); 20 static final TIRAMISU = new AndroidSdk(33, "13", "9030017"); 21 22 23 static final List<AndroidSdk> ALL_SDKS = [ 24 JELLY_BEAN, JELLY_BEAN_MR1, JELLY_BEAN_MR2, KITKAT, 25 LOLLIPOP, LOLLIPOP_MR1, M, N, N_MR1, O, O_MR1, P, Q, R, S, S_V2, 26 TIRAMISU 27 ] 28 29 static final MAX_SDK = Collections.max(ALL_SDKS) 30 31 public final int apiLevel 32 private final String androidVersion 33 private final String frameworkSdkBuildVersion 34 35 AndroidSdk(int apiLevel, String androidVersion, String frameworkSdkBuildVersion) { 36 this.apiLevel = apiLevel 37 this.androidVersion = androidVersion 38 this.frameworkSdkBuildVersion = frameworkSdkBuildVersion 39 } 40 41 String getGroupId() { 42 return "org.robolectric" 43 } 44 45 String getArtifactId() { 46 return "android-all" 47 } 48 49 String getPreinstrumentedArtifactId() { 50 return "android-all-instrumented" 51 } 52 53 String getVersion() { 54 return "${androidVersion}-robolectric-${frameworkSdkBuildVersion}" 55 } 56 57 String getPreinstrumentedVersion() { 58 return "${androidVersion}-robolectric-${frameworkSdkBuildVersion}-i${PREINSTRUMENTED_VERSION}" 59 } 60 61 String getCoordinates() { 62 return "${groupId}:${artifactId}:${version}" 63 } 64 65 String getPreinstrumentedCoordinates() { 66 return "${groupId}:${preinstrumentedArtifactId}:${preinstrumentedVersion}" 67 } 68 69 String getJarFileName() { 70 return "android-all-${androidVersion}-robolectric-${frameworkSdkBuildVersion}.jar" 71 } 72 73 String getPreinstrumentedJarFileName() { 74 return "android-all-instrumented-${preinstrumentedVersion}.jar" 75 } 76 77 @Override 78 int compareTo(AndroidSdk other) { 79 return apiLevel - other.apiLevel 80 } 81 82 boolean equals(o) { 83 if (this.is(o)) return true 84 if (getClass() != o.class) return false 85 86 AndroidSdk that = (AndroidSdk) o 87 88 if (apiLevel != that.apiLevel) return false 89 90 return true 91 } 92 93 int hashCode() { 94 return apiLevel 95 } 96} 97