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

Make robolectric-deps.properties public #92

Merged
merged 1 commit into from
Jan 26, 2024

Conversation

jylinv0
Copy link
Contributor

@jylinv0 jylinv0 commented Jan 25, 2024

Seems this properties file contains essential information that need to be passed from users if they don't have their custom properties files. Make it public so users can declare dependency on it.

Seems this properties files contain essential information that need to be passed from users if they don't have their custom properties files. Make it public so users can declare dependency on it.
Copy link
Collaborator

@Bencodes Bencodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine although i'm curious what information you need from the property.

@jylinv0
Copy link
Contributor Author

jylinv0 commented Jan 26, 2024

To launch robolectric, android_local_test in rules_android project needs to pass robolectric-deps.properties so robolectric knows where needed jar file is located. Not passing jar location mapping would cause an error like java.lang.IllegalArgumentException: Path is not a file: ./android-all-instrumented-7.0.0_r1-robolectric-r1-i4.jar.

Users can override the location of properties file used in android_local_test with their own, but by default android_local_test will pass the one embedded in @robolectric//bazel:android-all so it works out of box.

@Bencodes Bencodes merged commit a5b25a8 into robolectric:master Jan 26, 2024
5 checks passed
@jylinv0 jylinv0 deleted the patch-1 branch January 26, 2024 01:50
@utzcoz
Copy link
Member

utzcoz commented Jan 26, 2024

@jylinv0 Thanks for your contribution.

@utzcoz
Copy link
Member

utzcoz commented Jan 26, 2024

@jylinv0 @Bencodes What about writing some examples/documentation for this use-case? From my understanding, developers can use it to download android-all.jar based on their requirements in the codebase and use them directly to run Robolectric, like offline mode very much.

@Bencodes
Copy link
Collaborator

Here's an example of where it's being used https://github.com/bazelbuild/rules_android/pull/200/files#diff-dd8fdb04166b7ed1296b63b21ebc3ad01b0f5ebf71c0919aae354eb6c73581b4R178

@utzcoz this use case seems specific to rules_android and it's android_local_test implementation. I can't imagine this being needed more broadly outside of rules_android.

@jylinv0 you can find the properties file in the runfiles like this https://github.com/Bencodes/rules_kotlin/blob/blee/fork/master-napt-1.8-rules-android-pre-alpha/kotlin/internal/jvm/kt_android_local_test_impl.bzl#L178-L183 without needing to depend on the properties file directly.

@utzcoz
Copy link
Member

utzcoz commented Jan 26, 2024

@Bencodes Thanks for clarifying it. The run file looks great enough to customize it.

@ted-xie
Copy link
Contributor

ted-xie commented Feb 13, 2024

I'd be curious to see how the approach in kt_android_local_test (that Ben linked) scales. It does a linear search of all runfiles until it finds the properties file. If you have a really big app where the test has a lot of runfiles, it might take a long time, and you're essentially at the mercy of your persistent storage I/O speed and latency.

Is it possible to get a new rules_robolectric release with this PR included?

@utzcoz
Copy link
Member

utzcoz commented Feb 14, 2024

@ted-xie Sorry, robolectric-bazel keeps the same release cycle with robolectric/robolectric. So this robolectric-bazel version will be released after robolectric/robolectric new version release, maybe 4.12.

@Bencodes
Copy link
Collaborator

We could follow a release versioning strategy like KSP for cases like these https://github.com/google/ksp. A simplified version could look like 4.11.1-1 where 4.11.1 tracks upstream Robolectric and -1 tracks minor fixes inside the Bazel rules.

@utzcoz
Copy link
Member

utzcoz commented Feb 15, 2024

It looks great to me. What do you think about it @hoisie @brettchabot ?

@utzcoz
Copy link
Member

utzcoz commented Feb 15, 2024

@Bencodes I created an issue to discuss the potential new release version rule separately. #95.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants