title: Getting Gradle to use an artifact from a local maven repository
body: <p>I want to use a maven repository with cached artifacts that I have on my local computer to accelerate the Gradle build by avoiding downloading them.</p>
  
  <p>Unfortunately, what I notice is that even though the local repository is listed first and it has the dependency I need, Gradle will fetch the artifact from the Internet if an Internet connection is available and will only use the local repository if there is a problem getting to the network one.</p>
  
  <p>Here is one concrete small example that reproduces this issue:</p>
  
  <p><strong>build.gradle</strong>:</p>
  
  <pre><code>apply plugin: 'java'
  
  repositories {
    maven {
      name 'cache'
      url "/home/vagrant/m2copy"
    }
    jcenter()
  }
  
  dependencies {
    compile 'com.google.code.gson:gson:2.4'
  }
  
  jar {
    manifest {
      attributes 'Created-By': 'Ekumen'
    }
  }
  </code></pre>
  
  <p>The contents of <strong>/home/vagrant/m2copy</strong>:</p>
  
  <pre><code>m2copy:
  com
  
  m2copy/com:
  google
  
  m2copy/com/google:
  code
  
  m2copy/com/google/code:
  gson
  
  m2copy/com/google/code/gson:
  gson
  
  m2copy/com/google/code/gson/gson:
  2.4
  
  m2copy/com/google/code/gson/gson/2.4:
  gson-2.4.jar
  gson-2.4.jar.sha1
  _remote.repositories
  </code></pre>
  
  <p>And the output of a gradle build:</p>
  
  <pre><code>vagrant@vagrant-ubuntu-trusty-64:~/test_cache$ ./gradlew build
  :compileJava
  Download https://jcenter.bintray.com/com/google/code/gson/gson/2.4/gson-2.4.pom
  Download https://jcenter.bintray.com/org/sonatype/oss/oss-parent/9/oss-parent-9.pom
  Download https://jcenter.bintray.com/com/google/code/gson/gson/2.4/gson-2.4.jar
  :processResources UP-TO-DATE
  :classes
  :jar
  :assemble
  :compileTestJava UP-TO-DATE
  :processTestResources UP-TO-DATE
  :testClasses UP-TO-DATE
  :test UP-TO-DATE
  :check UP-TO-DATE
  :build
  
  BUILD SUCCESSFUL
  </code></pre>
  
  <p>Any ideas why is Gradle skipping the local repository on this case and only using it when there is no access to jcenter?</p>