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

SOCK5 support (compatible with Gradle itself) #8750

Open
tprochazka opened this issue Jan 17, 2024 · 2 comments
Open

SOCK5 support (compatible with Gradle itself) #8750

tprochazka opened this issue Jan 17, 2024 · 2 comments

Comments

@tprochazka
Copy link

Gradle itself has SOCK5 support simply by adding this to gradle.properties

systemProp.socksProxyHost=#.#.#.#
systemProp.socksProxyPort=1080
org.gradle.jvmargs=-DsocksProxyHost=#.#.#.# -DsocksProxyPort=1080

But Robolectric failing with
Failed to fetch maven artifact org.robolectric:android-all-instrumented:4.4_r1-robolectric-r2-i4

Why is it simply not using the existing dependency fetching mechanism directly from Gradle which will automatically work in this situation?

@utzcoz
Copy link
Member

utzcoz commented Jan 18, 2024

It's a complicated issue.

Currently, developers add Robolectric as dependency, and different people may use Robolectric to run tests for different Android SDK levels. Maybe one people only use Robolectric to run tests with SDK 34, and other people might use Robolectric to run tests across SDK 20 - SDK 34. So Robolectric encapsulates its internal logic to download necessary Robolectric's android-all jars based on test requirement separately. For the first scenario, Robolectric only downloads android-all for SDK 34. For the second scenario, Robolectric downloads multiple android-all jars for SDK 20 - SDK34.

And Robolectric uses preinstrumented-jars now, and its version often bumps, and one version for one SDK is a new android-all jar on maven. It's not easy for developers to use proper android-all jar dependency in Gradle directly, so Robolectric manages it internally.

Yep. Some people have suggested to create a Robolectric Gradle plugin for developers to configure and leverage Gradle's functionality to manage android-all jars with encapsulating details too from developers. But we don't have a great priority to support it.

If you need some tips to make android-all jars downloading become stable, you can check https://robolectric.org/blog/2023/11/11/improving-android-all-downloading/.

@hoisie
Copy link
Contributor

hoisie commented Jan 20, 2024

@tprochazka I am not aware of any standard socksProxy{Host,Port} system property. Looks like Robolectric supports robolectric.dependency.proxy.host and robolectric.dependency.proxy.port (https://github.com/robolectric/robolectric/blob/master/plugins/maven-dependency-resolver/src/main/java/org/robolectric/MavenRoboSettings.java#L25-L30).

If there is an improvement/enhancement related to Maven/Gradle we always welcome to PRs. A lot of teams have custom and esoteric maven environments that and have sent us PR to improve support.

FWIW, fetching android-all jars happens lazily because they tend to be quite large (e.g. ~150MiB for Android U). If we were to fetch them all upfront it would be many gigabytes and it's possible many of them would be unused. As a general rule, it is very difficult to know upfront which SDKs are required for a test suite, as there are five or six ways to configure the SDK level last time I checked.

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

No branches or pull requests

3 participants