Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase release branch #965

Merged
merged 1 commit into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ okbuck {
externalDependencies {
resolutionAction = "latest"
allowAllVersions = [
"org.robolectric:android-all",
"org.robolectric:android-all-instrumented",
]
autoValueConfigurations = [
"autoValueAnnotations",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ public void download() {
apisToDownload = EnumSet.allOf(API.class);
}

String preinstrumentedVersion =
ProjectUtil.getOkBuckExtension(rootProject).getTestExtension().robolectricPreinstrumentedVersion;

for (API api : apisToDownload) {
Configuration runtimeApi =
rootProject.getConfigurations().maybeCreate(ROBOLECTRIC_RUNTIME + "_" + api.name());
rootProject.getDependencies().add(runtimeApi.getName(), api.getCoordinates());
rootProject.getDependencies().add(runtimeApi.getName(), api.getCoordinates(preinstrumentedVersion));
runtimeDeps.add(runtimeApi);
}

Expand Down Expand Up @@ -116,10 +119,10 @@ enum API {
API_25("7.1.0_r7", "r1"),
API_26("8.0.0_r4", "r1"),
API_27("8.1.0", "4611349"),
API_P("P", "4651975"),
API_28("9", "4913185-2"),
API_29("10", "5803371"),
API_30("11", "6757853");
API_30("11", "6757853"),
API_31("12", "7732740");

private final String androidVersion;
private final String frameworkSdkBuildVersion;
Expand All @@ -129,11 +132,13 @@ enum API {
this.frameworkSdkBuildVersion = frameworkSdkBuildVersion;
}

String getCoordinates() {
return "org.robolectric:android-all:"
String getCoordinates(String preinstrumentedVersion) {
return "org.robolectric:android-all-instrumented:"
+ androidVersion
+ "-robolectric-"
+ frameworkSdkBuildVersion;
+ frameworkSdkBuildVersion
+ "-"
+ preinstrumentedVersion;
}

static API from(String apiLevel) {
Expand Down Expand Up @@ -166,8 +171,8 @@ static API from(String apiLevel) {
return API_29;
case "30":
return API_30;
case "P":
return API_P;
case "31":
return API_31;
default:
throw new IllegalStateException("Unknown Robolectric API Level: " + apiLevel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ExternalDependenciesExtension {
* dependencies like robolectric runtime deps.
*/
@Input
private List<String> allowAllVersions = Collections.singletonList("org.robolectric:android-all");
private List<String> allowAllVersions = Collections.singletonList("org.robolectric:android-all-instrumented");

/**
* Stores the dependency versions to be used for dynamic notations that have , or + in their
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ public class TestExtension {
*/
@Nullable public Set<String> robolectricApis = null;

/**
* Specify the preinstrumented version of artifacts to be used.
* Hardcoded in Robolectric
* https://github.com/robolectric/robolectric/blob/master/robolectric/src/main/java/org/robolectric/plugins/DefaultSdkProvider.java#L50
*/
public String robolectricPreinstrumentedVersion = "i3";

/** Enable generation of espresso test rules. */
public boolean espresso = false;

Expand Down
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test = [
junit : "junit:junit:4.13.2",
kotlinTest : "org.jetbrains.kotlin:kotlin-test-junit:${versions.kotlin}",
mockito : "org.mockito:mockito-core:3.8.0",
robolectric : "org.robolectric:robolectric:4.5.1",
robolectric : "org.robolectric:robolectric:4.7.3",
scalaTest : "org.scalatest:scalatest_sjs1_2.13:3.2.0",
scalaTestJunit: "org.scalatestplus:junit-4-12_2.13:3.2.2.0",
testExt : "androidx.test.ext:junit:1.1.2-rc01",
Expand Down