This message was deleted.
# configuration-cache
s
This message was deleted.
m
This does not seem to work:
Copy code
public class RedisBuildCachePlugin implements Plugin<Settings> {
    @Override
    public void apply(Settings settings) {
        BuildCacheConfiguration buildCacheConfiguration = settings.getBuildCache();
        buildCacheConfiguration.registerBuildCacheService(RedisBuildCache.class, RedisBuildCacheServiceFactory.class);
    }

    static class RedisBuildCacheServiceFactory implements BuildCacheServiceFactory<RedisBuildCache> {
        @Override
        public BuildCacheService createBuildCacheService(RedisBuildCache configuration, Describer describer) {
            return new RedisBuildCacheService(configuration);
        }
    }
}
It results in this when gradle is trying to re-use a cached entry:
Copy code
org.gradle.initialization.exception.InitializationException: Gradle could not start your build.
        at org.gradle.initialization.exception.DefaultExceptionAnalyser.collectFailures(DefaultExceptionAnalyser.java:65)
        at org.gradle.initialization.exception.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:55)
        at org.gradle.initialization.exception.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:39)
        [...]
Caused by: org.gradle.internal.service.ServiceCreationException: Could not create service of type BuildCacheController using .createBuildCacheController().
        at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:898)
        [...]
Caused by: org.gradle.api.GradleException: Build cache type 'com.company.gradle.cache.RedisBuildCache_Decorated' has not been registered.
        at org.gradle.caching.configuration.internal.DefaultBuildCacheConfiguration.getBuildCacheServiceFactoryType(DefaultBuildCacheConfiguration.java:155)
        at org.gradle.caching.configuration.internal.DefaultBuildCacheConfiguration.getBuildCacheServiceFactoryType(DefaultBuildCacheConfiguration.java:142)
        at org.gradle.caching.internal.services.BuildCacheControllerFactory.createBuildCacheService(BuildCacheControllerFactory.java:158)
        [...]
m
What version of Gradle do you use? The support for custom build caches with the configuration cache was added in 7.5
m
Thanks, that solved my problem! I'm on 7.4.2, but I thought I was also testing with 7.6 after doing a
gradlew wrapper --gradle-version 7.6-rc-3
, but it turns out that this is silently ignored when a wrapper task is configured in code (which we do to not constantly download from the public internet in our CI). So as a follow-up: is it possible to use a custom download location and support
wrapper --gradle-version nnn
at the same time?
m
It is possible, yes. See https://github.com/gradle/gradle/issues/21493 for the details. Right now we have to use internal property definitions but it does work.
thank you 1
m
Thanks, that property does look interesting, but I cannot seem to make it work. Setting it on the commandline with
-D
or
-P
produces no different result from not setting it, same as putting it into the project's
gradle.properties
or my user properties (the latter with and without
systemProp.
prefix). How do you use that?
m
We use it in our project's gradle.properties file as follows:
Copy code
systemProp.org.gradle.internal.plugins.portal.url.override=<https://server/path/etc/>
You'd still need to modify the distribution URL in
gradle/wrapper/gradle-wrapper.properties
as well
I generally use the wrapper task to do the updates and then manually tweak the distribution URL after it is done
m
I don't think I understand what this property is supposed to do if it's not about setting the correct URL in
gradle-wrapper.properties
(which is all I really care about).
m
The combination of the property plus the
gradle-wrapper.properties
tweak causes all gradle-related stuff (plugins, gradle implementation referenced by gradlew, etc.) to be pulled through a proxy cache of your choosing. I think I misunderstood the nuance of your follow-up question so my suggestion won't solve your issue completely.
m
Thanks, I wasn't aware that this URL was used for anything but the wrapper properties, but
plugins.portal
strongly suggests that it is. I think I was just too focused on my own needs 🙂
👍 1