code: @SuppressWarnings("unchecked")
      private static <T> T getCachedReference(Project project, String key, Supplier<T> supplier) {
          if (project == null) {
              throw new IllegalArgumentException("Gradle project reference cannot be null.");
          }
  
          Project rootProject = project.getRootProject();
          ExtraPropertiesExtension ext = rootProject.getExtensions().getExtraProperties();
          T value;
          if (ext.has(key)) {
              value = (T) ext.get(key);
          } else {
              value = supplier.get();
              ext.set(key, value);
          }
          return value;
      }
docs: Get data (identified by the given key) that has been cached on the given Gradle project reference.
  
  @param project  the Gradle project reference.
  @param key      the key used for caching the data.
  @param supplier the function that needs to be executed in the event of a cache-miss.
  @param <T>      the type of the data stored on the project.
  @return data that has been cached on the given Gradle project reference.