How can I download Gradle plugins for offline use? I need to be able to collect the minimal set of dependencies, move to another machine, and build offline.
I know how to do this for build dependencies (e.g. apache commons and its transitive set of dependencies) by creating a local maven repo on the file system, but the same approach doesn’t seem to work for Gradle Plugins. I need to also collect Gradle plugins that will be applied offline. I would prefer not to have to move an entire user gradle directory or setup a Maven mirror with Nexus or Artifactory. There has to be a straightforward way to produce a local maven repo (or similar artifact) that I can move to an offline build environment.
I’ve found that with some success I can pilfer ~/.gradle/caches
and re-export as a maven repo (e.g. How to cache Gradle build dependencies to a local Maven repository), but not all plugins follow conventional cache layouts (e.g. foojay resolver plugin). The cache approach also makes it difficult to package up only the dependencies that are needed to build (it conflates cached plugins from other projects and lazily fetches so it requires exercising all the plugins of the build to ensure the cache is properly populated). This is slow and error prone to maintain.
For example, if my build requires this plugin, how can I download it to a local repo so that I can include it later offline?
plugins {
id("com.netflix.nebula.ospackage") version "11.11.2"
}
then later load it with:
pluginManagement {
repositories {
// first search local offline repo
maven {
url "${rootDir}/local-m2"
}
// fallback to online
gradlePluginPortal()
}
}
This problem seems entirely too difficult yet common place enough that I’m not sure why I can’t find an easy solution to this. What am I missing?