Enable offline mode using gradle.properties?

I know I can do gradlew --offline. Is there a property that I can set in gradle.properties which accomplishes this same thing?

While I’m developing, I’ve got a lot of -SNAPSHOT versions, and I use the

configurations.all {
    resolutionStrategy.cacheChangingModfulesFor 0, 'seconds'
}

trick to keep them up-to-date. But when I’m on an airplane or trying to focus at a non-wifi coffeeshop, I have to specify --offline for every gradle call I make or I’ll get a build error. The really rotten thing is I don’t get that build error until after a ~10 second timeout, and I forget it a lot.

So, is there a timeout property, and if not, how can I go about contributing one?

Although it is not setting a property in gradle.properties, you could set the offline property without having to remember it on each call by using an Init Script. The init script can be placed in a location that affects all your builds or just one, just like the user or project specific gradle.properties. See the documentation for the valid paths to put it.

Put this line in the init script:
startParameter.offline=true

2 Likes

Works perfect, thanks!