@VisibleForTesting // recursive (but doesn't search through nested objects, only nested extensions) 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; } 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(); }
public ExtensionContainerInternal getExtensions() { return (ExtensionContainerInternal) getConvention(); }
ExtensionContainerInternal getExtensions();