@NotNull
 private static Map<String, IdeaAppEngineProject> indexByModuleName(
     @NotNull Collection<DataNode<IdeaAppEngineProject>> dataNodes) {
   Map<String, IdeaAppEngineProject> index = Maps.newHashMap();
   for (DataNode<IdeaAppEngineProject> d : dataNodes) {
     IdeaAppEngineProject appEngineProject = d.getData();
     index.put(appEngineProject.getModuleName(), appEngineProject);
   }
   return index;
 }
  @NotNull
  private static AppEngineGradleFacet addAppEngineGradleFacet(
      IdeaAppEngineProject ideaAppEngineProject, Module appEngineModule) {
    FacetManager facetManager = FacetManager.getInstance(appEngineModule);
    ModifiableFacetModel model = facetManager.createModifiableModel();
    AppEngineGradleFacet facet = AppEngineGradleFacet.getInstance(appEngineModule);
    if (facet == null) {
      // Module does not have AppEngine-Gradle facet. Create one and add it.
      try {
        facet =
            facetManager.createFacet(
                AppEngineGradleFacet.getFacetType(), AppEngineGradleFacet.NAME, null);
        model.addFacet(facet);
      } finally {
        model.commit();
      }
    }

    // deserialize state from ideaAppEngineProject into facet config.
    if (facet != null) {
      facet.getConfiguration().getState().APPENGINE_SDKROOT =
          ideaAppEngineProject.getDelegate().getAppEngineSdkRoot();
      facet.getConfiguration().getState().HTTP_ADDRESS =
          ideaAppEngineProject.getDelegate().getHttpAddress();
      facet.getConfiguration().getState().HTTP_PORT =
          ideaAppEngineProject.getDelegate().getHttpPort();
      facet.getConfiguration().getState().JVM_FLAGS.clear();
      for (String flag : ideaAppEngineProject.getDelegate().getJvmFlags()) {
        facet.getConfiguration().getState().JVM_FLAGS.add(flag);
      }
      facet.getConfiguration().getState().WAR_DIR =
          ideaAppEngineProject.getDelegate().getWarDir().getAbsolutePath();
      facet.getConfiguration().getState().WEB_APP_DIR =
          ideaAppEngineProject.getDelegate().getWebAppDir().getAbsolutePath();
      facet.getConfiguration().getState().DISABLE_UPDATE_CHECK =
          ideaAppEngineProject.getDelegate().isDisableUpdateCheck();
    }
    return facet;
  }