Repository: react-native
Issue: Add support for Gradle Configuration Cache
Labels: Help Wanted :octocat:,Type: Enhancement,Tool: Gradle,Never gets stale

### Description

Using Gradle 8.2 or newer with stable config cache support, enabling it with org.gradle.configuration-cache=true I'm getting this error:

```
4 problems were found storing the configuration cache, 2 of which seem unique.
- Script '/Users/..../node_modules/@react-native-community/cli-platform-android/native_modules.gradle': external process started 'node -e try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}'
  See https://docs.gradle.org/8.2.1/userguide/configuration_cache.html#config_cache:requirements:external_processes
```
```
org.gradle.api.InvalidUserCodeException: Starting an external process 'node -e try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}' during configuration time is unsupported.
	at org.gradle.configurationcache.initialization.DefaultConfigurationCacheProblemsListener.onExternalProcessStarted(ConfigurationCacheProblemsListener.kt:117)
	at org.gradle.configurationcache.InstrumentedInputAccessListener.externalProcessStarted(InstrumentedInputAccessListener.kt:110)
	at org.gradle.internal.classpath.Instrumented.externalProcessStarted(Instrumented.java:501)
```

Currently we're wasting 30s to 1 minute on configuration step every time we build, also locally. 
I reported it almost a year ago in https://github.com/react-native-community/cli/issues/2058, now it being closed there I should recreate it here.

### Steps to reproduce

Using Gradle 8.2 or newer with stable config cache support, enabling it with org.gradle.configuration-cache=true I'm getting this error:

### React Native Version

0.74.0

### Affected Platforms

Build - MacOS

### Output of `npx react-native info`

```text
irrelevant
```


### Stacktrace or Logs

```text
4 problems were found storing the configuration cache, 2 of which seem unique.
- Script '/Users/..../node_modules/@react-native-community/cli-platform-android/native_modules.gradle': external process started 'node -e try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}'
  See https://docs.gradle.org/8.2.1/userguide/configuration_cache.html#config_cache:requirements:external_processes
```
```
org.gradle.api.InvalidUserCodeException: Starting an external process 'node -e try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}' during configuration time is unsupported.
	at org.gradle.configurationcache.initialization.DefaultConfigurationCacheProblemsListener.onExternalProcessStarted(ConfigurationCacheProblemsListener.kt:117)
	at org.gradle.configurationcache.InstrumentedInputAccessListener.externalProcessStarted(InstrumentedInputAccessListener.kt:110)
	at org.gradle.internal.classpath.Instrumented.externalProcessStarted(Instrumented.java:501)
```
```


### Reproducer

irrelevant, issue is clear in the description

### Screenshots and Videos

_No response_