# Partial configuration cache

**URL:** <https://discuss.gradle.org/t/partial-configuration-cache/47880>\
**Category:** Help/Discuss\
**Created:** [March 6, 2024, 3:13pm UTC](https://discuss.gradle.org/t/partial-configuration-cache/47880 "2024-03-06T15:13:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nitinsethi86](https://avatars.discourse-cdn.com/v4/letter/n/8edcca/32.png) [@nitinsethi86](https://discuss.gradle.org/u/nitinsethi86)\
**Post date:** [March 6, 2024, 3:13pm UTC](https://discuss.gradle.org/t/partial-configuration-cache/47880/1 "2024-03-06T15:13:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [March 6, 2024, 3:45pm UTC](https://discuss.gradle.org/t/partial-configuration-cache/47880/2 "2024-03-06T15:45:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nitinsethi86](https://avatars.discourse-cdn.com/v4/letter/n/8edcca/32.png) [@nitinsethi86](https://discuss.gradle.org/u/nitinsethi86)\
**Post date:** [March 7, 2024, 2:58am UTC](https://discuss.gradle.org/t/partial-configuration-cache/47880/3 "2024-03-07T02:58:11Z")

</div>

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

```gradle
             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.

```gradle
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}")
            }

```

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [March 7, 2024, 10:05am UTC](https://discuss.gradle.org/t/partial-configuration-cache/47880/4 "2024-03-07T10:05:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nitinsethi86](https://avatars.discourse-cdn.com/v4/letter/n/8edcca/32.png) [@nitinsethi86](https://discuss.gradle.org/u/nitinsethi86)\
**Post date:** [March 7, 2024, 11:01am UTC](https://discuss.gradle.org/t/partial-configuration-cache/47880/5 "2024-03-07T11:01:19Z")

</div>

Understood, thanks @Vampire !
