title: How to override the Robolectric runtime dependency repository URL?
body: <p>We're trying to use the <code>org.robolectric:robolectric:3.0</code> dependency from our own internal Nexus repository.  The issue is that Robolectric tries to load some dependencies at runtime from a public repository (<a href="https://github.com/robolectric/robolectric/issues/571" rel="noreferrer">as mentioned here</a>), and ignores any repository overrides in the build.gradle.</p>
  
  <p>Since we don't have access to that public location from our intranet, my tests timeout after trying to load that dependency:</p>
  
  <blockquote>
    <p>[WARNING] Unable to get resource
    'org.robolectric:android-all:jar:5.0.0_r2-robolectric-1' from
    repository sonatype (<a href="https://oss.sonatype.org/content/groups/public/" rel="noreferrer">https://oss.sonatype.org/content/groups/public/</a>):
    Error transferring file: Operation timed out</p>
  </blockquote>
  
  <p>The bottom section of the <a href="http://robolectric.org/configuring/" rel="noreferrer">Robolectric configuration documentation</a> recommends adding this to your Gradle configuration to override the URL:</p>
  
  <pre><code>android {
    testOptions {
      unitTests.all {
        systemProperty 'robolectric.dependency.repo.url', 'https://local-mirror/repo'
        systemProperty 'robolectric.dependency.repo.id', 'local'
      }
    }
  }
  </code></pre>
  
  <p>Unfortunately, I've tested that and I never see that system property being set.  I've printed it out from inside my custom Robolectric runner (which extends <code>RobolectricGradleTestRunner</code>) and that system property remains set to null.</p>
  
  <pre><code>System.out.println("robolectric.dependency.repo.url: " + System.getProperty("robolectric.dependency.repo.url"));
  </code></pre>
  
  <p>I also tried to do something similar to <a href="https://github.com/robolectric/robolectric/issues/571#issuecomment-18950567" rel="noreferrer">this comment</a> (but that method doesn't exist to override in <code>RobolectricGradleTestRunner</code>), and I also tried setting the system properties directly in my custom Robolectric runner, and that didn't seem to help.</p>
  
  <pre><code>@Config(constants = BuildConfig.class)
  public class CustomRobolectricRunner extends RobolectricGradleTestRunner {
      private static final String BUILD_OUTPUT = "build/intermediates";
  
      public CustomRobolectricRunner(Class&lt;?&gt; testClass) throws InitializationError {
          super(testClass);
  
          System.setProperty("robolectric.dependency.repo.url", "https://nexus.myinternaldomain.com/content");
          System.setProperty("robolectric.dependency.repo.id", "internal");
  
          System.out.println("robolectric.dependency.repo.url: " + System.getProperty("robolectric.dependency.repo.url"));
      }
  </code></pre>
  
  <p>The <a href="https://github.com/robolectric/robolectric/blob/78ef7facd8df6c2c2f8dafedfbc2d1af19f3558e/robolectric-resources/src/main/java/org/robolectric/RoboSettings.java" rel="noreferrer">Robolectric source code</a> does seem to confirm that these system properties exist.</p>