private static void writeProject(IonWriter writer, WriteContext context, ExternalProject project) throws IOException {
    context.getProjectsCollector().add(project, (isAdded, objectId) -> {
      writer.stepIn(IonType.STRUCT);
      writeInt(writer, OBJECT_ID_FIELD, objectId);
      if (isAdded) {
        writeString(writer, PROJECT_ID_FIELD, project.getId());
        writeString(writer, PROJECT_PATH_FIELD, project.getPath());
        writeString(writer, PROJECT_IDENTITY_PATH_FIELD, project.getIdentityPath());
        writeString(writer, PROJECT_NAME_FIELD, project.getName());
        writeString(writer, PROJECT_Q_NAME_FIELD, project.getQName());
        writeString(writer, PROJECT_DESCRIPTION_FIELD, project.getDescription());
        writeString(writer, PROJECT_GROUP_FIELD, project.getGroup());
        writeString(writer, PROJECT_VERSION_FIELD, project.getVersion());
        writeString(writer, PROJECT_DIR_FIELD, project.getProjectDir().getPath());
        writeString(writer, PROJECT_BUILD_DIR_FIELD, project.getBuildDir().getPath());
        writeFile(writer, PROJECT_BUILD_FILE_FIELD, project.getBuildFile());
        writeSourceSetModel(writer, context, project);
        writeTaskModel(writer, project);
        writeChildProjects(writer, context, project);
      }
      writer.stepOut();
    });
  }
private static void writeProject(IonWriter writer, WriteContext context, ExternalProject project)