static String getExtensionData()

in app-gradle-plugin/src/main/java/com/google/cloud/tools/gradle/appengine/core/ShowConfigurationTask.java [58:98]


  static String getExtensionData(String extensionName, Object extensionInstance, int depth)
      throws IllegalAccessException {
    StringBuilder result = new StringBuilder("");
    // extension start block
    result.append(spaces(depth)).append(extensionName).append(" {\n");

    // all non-extension fields
    for (Field field : extensionInstance.getClass().getSuperclass().getDeclaredFields()) {
      // ignore synthetic fields (stuff added by compiler or instrumenter)
      if (field.isSynthetic()) {
        continue;
      }
      // This is just a helper for the extensions, don't show it
      if (field.getType().equals(org.gradle.api.Project.class)) {
        continue;
      }
      // ignore fields marked with InternalProperty
      if (field.getAnnotationsByType(InternalProperty.class).length > 0) {
        continue;
      }
      result.append(getFieldData(field, extensionInstance, depth + 1));
    }

    // all extension fields
    Map<String, Object> map =
        ((ExtensionContainerInternal) ((ExtensionAware) extensionInstance).getExtensions())
            .getAsMap();
    for (String childExtensionName : map.keySet()) {
      Object childExtensionInstance = map.get(childExtensionName);
      // only expand out extensions we understand (we're ignoring the default ext group here, which
      // is not ExtensionAware)
      if (childExtensionInstance instanceof ExtensionAware) {
        result.append(getExtensionData(childExtensionName, map.get(childExtensionName), depth + 1));
      }
    }

    // extension end block
    result.append(spaces(depth)).append("}\n");

    return result.toString();
  }