Disable Plugin Caching using init-Script

Hi,

I’m trying to disable the dynamic version caching for Gradle Plugins for all our builds. I thought about using an init-Script in a custom Gradle-Distribution. I tried the beforeSettings-Closure, but unfortunately settings.pluginManagement.resolutionStrategy has no cacheChangingModulesFor-Method.

Using a buildscript inside the init-Script does not seem to work either:

beforeSettings {
		settings.buildscript.configurations.all {
				resolutionStrategy {
						cacheChangingModulesFor(0, TimeUnit.SECONDS)
			 }
		}
}

There is an open issue (PluginManagement block's resolution strategy cache configuration · Issue #22737 · gradle/gradle · GitHub), but that has not seen attention since Nov 2022.

Regards,
Daniel

1 Like

I never tried that, so just guessing here.
But I think your problem is, that this would only wok for settings plugins as you only set it on settings buildscript configurations.
You probably need to do the same for the buildscript configurations of all projects.

Besides that, cacheChangingModulesFor is for things like ...-SNAPSHOT that are defined as “changing content without changing version number”, not for “dynamic version resolution”. There is a sibling method for that one that you probably intended to use unless “dynamid version caching” was just unlucky wording. :slight_smile:

I intend to use it for our SNAPSHOT-Plugins, so yes, bad wording.

Is there a way to do this for all projects using an init-script? I really don’t want to copy & paste this all over the place.

Probably with allprojects { ... } in the init script.

Seems like it’s working now. But how about a settings-plugin? We use that to have a toml-file shared between numerous projects. As far as I understood this one is resolved before any project, so allprojects won’t help in this case.

You probably just need both in your init script