Gradle Caching configuration does not work init.d

The below script to do dynamic caching for 60 seconds works fine when put in the project build.gradle file individually, but does not work when put under the init.d file
buildscript {
configurations.classpath {
resolutionStrategy {
cacheDynamicVersionsFor 60, ‘seconds’
cacheChangingModulesFor 0, ‘seconds’
}
}

The intention here is if a project uses a specific gradle version while building dependency, caching will prevent talking to server. + dynamic version number, default behaviour is to check the new version every [whatever time configured]. If there is a need to roll out a hot fix, build does not pick up every [whatever time defined].

For this code to take effect in a multi-project build, it needs to be wrapped in allprojects { ... }. Does this solve your problem? Note that this code configures a resolution strategy for build script dependencies (i.e., Gradle plugins) but not for regular dependencies.

Hey Fred,

Thanks for the response. Yes I forgot to add the allProjects snippet, but had tested out with that also but this was not helping at all. We are using it for gradle plugins.

/// Plugin caching
buildscript.configurations.classpath {
resolutionStrategy {
// cache dynamic versions (+) for 10 minutes
cacheDynamicVersionsFor 10, TimeUnit.MINUTES

    // don't cache changing modules at all
    cacheChangingModulesFor 0, TimeUnit.SECONDS
}

}

// Dependency caching
allprojects {
configurations.all {
resolutionStrategy {
// cache dynamic versions (+) for 10 minutes
cacheDynamicVersionsFor 1, TimeUnit.HOURS

        // don't cache changing modules at all
        cacheChangingModulesFor 0, TimeUnit.SECONDS
    }
}

}

You should definitely use allprojects in both cases, not just for regular dependencies as shown in your code. If that alone doesn’t help, I don’t know what the problem is.

Thanks Fred Curts the solution worked.