I am trying to create a copy of a gradle project that will work in --offline
mode. I have automated all steps apart from one. I am not able to automatically download plugin jars into gradle cache.
My offline distribution works by specifying the GRADLE_USER_HOME
, downloading all dependencies and bundling the whole gradle cache with the project. Unfortunately we are using a few custom plugins. I could of course make an exception for each one of them and include them manually, with some kind of if
statement for the offline mode. But it would be great if I could simply download the jars into the cache.
Is there a way to force gradle to download all dependencies, including the plugin dependencies?
This is what I am doing for the rest of the dependencies:
task resolveAllDependencies {
doLast {
configurations.all { it.resolve() }
}
}
It downloads all dependencies to the local cache. But plugins are of course not included in any of the configurations.
It also seems that even if the plugin gets downloaded in the cache, it still fails in offline mode with the following message: Plugin cannot be resolved from https://plugins.gradle.org/api/gradle because Gradle is running in offline mode
Here's a working solution. It's not perfect, because it hard-codes the gradle plugin repository and changes the script. It's also much more verbose than the current way of using plugins.
Instead of the following simple plugin definition:
plugins {
id 'net.researchgate.release' version '2.3.5'
}
It's possible to define both the repository and the dependency manually and then use the plugin this way:
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'net.researchgate:gradle-release:2.3.5'
}
}
apply plugin: 'net.researchgate.release'
This downloads the plugin into the local gradle cache.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With