Gradle Plugins Offline Resolution

Hello, I am attempting to design a Gradle project with the following requirements:

  1. No internet access.
  2. No pre-existing Gradle cache
  3. A portable Maven repository containing all necessary plugins and dependencies.

I have been able to get external dependencies to resolve in an offline environment without a Gradle cache already, but plugin resolution fails and I haven’t found a solution despite multiple attempts.

As a simple example of what I’m shooting for, here is my build.gradle

plugins {
    id 'java'
    id "com.google.protobuf" version "0.8.6"
}
dependencies {
    compile "junit:junit:4.12"
}
repositories {
    maven {
        url "file://${project.projectDir}/mavenRepo"
    } 	
    jcenter()
}

And my settings.gradle:

pluginManagement {
    repositories {
        maven {
            url "file:mavenRepo"
        }
    gradlePluginPortal()
    }
}

The error I get is:

* Where:
Build file '/home/user/git/project/build.gradle' line: 6

* What went wrong:
Plugin [id: 'com.google.protobuf', version: '0.8.6'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.google.protobuf:com.google.protobuf.gradle.plugin:0.8.6')
  Searched in the following repositories:
    maven(file:/home/user/git/project/mavenRepo/)
    Gradle Central Plugin Repository

There must be some step I’m missing here, or something I’ve got confused about dependencies and plugins. If anyone can offer help, I’d greatly appreciate it!

The plugins { ... } block method of applying plugins requires a way to map the com.google.protobuf plugin ID to the Maven coordinates of the artifact. It uses a POM file as a marker interface using the format ${pluginId}:${pluginId}.gradle.plugin:${pluginVersion}.

You likely have the artifact for gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.6, but not the marker interface com.google.protobuf:com.google.protobuf.gradle.plugin:0.8.6 which would be found at https://plugins.gradle.org/m2/com/google/protobuf/com.google.protobuf.gradle.plugin/0.8.6/com.google.protobuf.gradle.plugin-0.8.6.pom

Thanks for the answer. That makes sense, where would the additional .pom file fit into the Maven repository’s structure? Would I manually put it alongside the .jar and .pom cached by Gradle’s initial download?

As of now, I’ve copied the cached files from ~/.gradle/caches/modules-2/files-2.1/ into what I believe is Maven’s correct format for my offline repository (mavenRepo in my above example). My current structure is below (which works for dependencies).

gradle.plugin.com.google.protobuf
|_ protobuf-gradle-plugin
     |_ 0.8.6 
          |_ protobuf-gradle-plugin-0.8.6.jar
          |_ protobuf-gradle-plugin-0.8.6.pom 

If you take the URL to the POM posted above, and strip off the https://plugins.gradle.org/m2/, thats the appropriate path in the Maven repository structure. Also, for the other dependencies, the standard Maven repository structure has the group separated by slashes (many folders) rather than one folder separated by dots.