Partial configuration cache

We have turned on configuration cache for our project by default. However, some tasks like ktLintFormat, pmd etc. from older plugins (we are yet to update) require us to pass --no-configuration-cache for successful run.

I am looking for ways to determine if --no-configuration-cache has been passed for specific task runs and fail fast and provide pointers via error logs to nudge developers to include the option so that the tasks run successfully. This is required temporarily until we move to versions that support configuration cache.

Thanks.

As it works when not calling those tasks, I guess it is not about things like build listeners, but about things like using project at execution time.
If that’s the case, just call notCompatibleWithConfigurationCache() for those tasks and you should not need to use that flag manually.

Turns out that the issue was usage of filter as below:

             exclude { element ->
                if (OperatingSystem.current().isWindows()) {
                    checkIfShouldExcludeWindows(element.file.path)
                } else {
                    checkIfShouldExcludeOtherOs(element.file.path)
                }
            }

Once i changed to below, it started working. I am curious to know the theory behind it.

exclude { FileTreeElement element ->
                def path = element.file.path
                def separator = File.separator
                path.contains("generated${separator}") ||
                        path.contains("generatedSrc${separator}") ||
                        path.contains("graphql${separator}com${separator}microsoft${separator}teams${separator}location${separator}services${separator}network${separator}") ||
                        path.contains("libs${separator}react-native${separator}") ||
                        path.contains("features${separator}roomcontroller${separator}") ||
                        path.contains("features${separator}pdfviewer${separator}") ||
                        path.contains("features${separator}peoplecontactsv2${separator}") ||
                        path.contains("common${separator}asyncmedia${separator}")
            }

You probably have those methods defined in the enclosing script.
So by referencing those methods, you are referencing the enclosing script and that is not CC compatible.
If you for example wrap them in a class - even with then script - and make them static functions, you should be able to use them there in a CC-compatible way.

1 Like

Understood, thanks @Vampire !

1 Like