title: Gradle Offline Build Using Maven Repository
body: <p>I'm attempting to setup an offline Gradle build. </p>
  
  <p>I would ideally like to have all my project dependencies in an arbitrary maven repository referenced as below: </p>
  
  <pre><code>repositories {
      maven {
          url 'file://PATH/TO/REPO'
      }
  }
  </code></pre>
  
  <p>However, the above fails in a fresh Gradle install (no ~/.gradle cache) with the following: </p>
  
  <pre><code>* What went wrong
  Plugin [id: PLUGINID, version: PLUGINVERSION] was not found in any of the 
  following sources:
  
  - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
  - Plugin Repositories (could not resolvee plugin artifact     'PLUGINID:PLUGINNAME:PLUGINVERSION')
      Searched in the following repositories: 
          Gradle Central Plugin Repository 
  </code></pre>
  
  <p>I've tried a few different ways to specify the repository, including: </p>
  
  <ol>
  <li>Replacing "url..." with "flatDir { dir '/PATH/TO/REPO' }".</li>
  <li>Copying all dependencies to ~/.m2 and calling mavenLocal() as the repository.</li>
  </ol>
  
  <p>To copy dependencies from ~/.gradle/caches/modules-2/files-2.1/ into my "offline" repository, I have tried:</p>
  
  <ol>
  <li>Straight copy/paste</li>
  <li><p>A Gradle task which converts the structure as such: </p>
  
  <pre><code>task cacheLocal(type: Copy) {
      from new File(gradle.gradleUserHomeDir, 'caches/modules-2/files-2.1')
      into '/PATH/TO/REPO'
      eachFile {
          List&lt;String&gt; parts = it.path.split('/')
          it.path = (parts[0] + '/' + parts[1]).replace('.','/') + '/' + parts[2] + '/' + parts[4]
      }
      includeEmptyDirs = false
   }
  </code></pre></li>
  </ol>
  
  <p>Other things:</p>
  
  <ul>
  <li>Running with "--offline" makes no difference.</li>
  <li>Build is successful if ~/.gradle is already present, but fails otherwise. </li>
  </ul>
  
  <p>My plugins block (the above error statement will hit the first non-Gradle core plugin, so protobuf in this case): </p>
  
  <pre><code>plugins {
      id "com.google.protobuf" version "0.8.6"
      id "nebula.ospackage" version "4.9.3"
      id "java"
      id "eclipse"
  }
  </code></pre>
  
  <p>This is out of my depth and any help would be greatly appreciated!</p>