Letting Gradle --offline work in hybrid mode


(Misagh Moayyed) #1

Background

I had initially reported this request to IntelliJ IDEA, but figured it might find a better home here.
https://youtrack.jetbrains.com/issue/IDEA-179100

Running Gradle 4.2.1 with a Java8 based project:

Proposal

Running Gradle with --offline is excellent; it provides significant performance improvements specially when internet connectivity is less than great. However, it’s a bit of a “boolean” flag that either affects everything or nothing. I would like to propose a bit of a smarter/hybrid behavior that might work like this:

The offline flag should be able to turn itself on and off again when needed, specially when Gradle determines that a dependency is not available in offline mode. Today, in that situation the build is stopped with an error message that says something to the effect of No cached version of X is available in offline mode. When this case is encountered, Gradle should try to automatically take itself back online, consulting repositories defined in the build to locate and download the dependency, and when done/successful take itself back offline again.

This should continue to provide the same performance improvements, and not abruptly end the build. Today, one has to take the build back online manually by removing --offline from the build command, let it download and resolve dependencies and then specify the flag again. Why do that manually, if it can be automated as a new mode/option?


(Sterling Greene) #2

That’s the default behavior without --offline. Gradle doesn’t need to check a remote repository unless its missing a dependency.

If you’re looking for something where you can have dynamic/changing dependencies that are locked to particular versions until you decide to change them, you can look at something like the nebula dependency lock plugin.


(Misagh Moayyed) #3

Thanks for the explanation. I apologize for my misunderstanding.