private void importMissingProjectLibraries(
     @NotNull Module module,
     @NotNull Collection<DataNode<LibraryDependencyData>> nodesToImport,
     boolean synchronous) {
   LibraryTable libraryTable = myPlatformFacade.getProjectLibraryTable(module.getProject());
   List<DataNode<LibraryData>> librariesToImport = ContainerUtilRt.newArrayList();
   for (DataNode<LibraryDependencyData> dataNode : nodesToImport) {
     final LibraryDependencyData dependencyData = dataNode.getData();
     if (dependencyData.getLevel() != LibraryLevel.PROJECT) {
       continue;
     }
     final Library library = libraryTable.getLibraryByName(dependencyData.getName());
     if (library == null) {
       DataNode<ProjectData> projectNode = dataNode.getDataNode(ProjectKeys.PROJECT);
       if (projectNode != null) {
         DataNode<LibraryData> libraryNode =
             ExternalSystemApiUtil.find(
                 projectNode,
                 ProjectKeys.LIBRARY,
                 new BooleanFunction<DataNode<LibraryData>>() {
                   @Override
                   public boolean fun(DataNode<LibraryData> node) {
                     return node.getData().equals(dependencyData.getTarget());
                   }
                 });
         if (libraryNode != null) {
           librariesToImport.add(libraryNode);
         }
       }
     }
   }
   if (!librariesToImport.isEmpty()) {
     myLibraryManager.importData(librariesToImport, module.getProject(), synchronous);
   }
 }
 private void importMissing(
     @NotNull Set<LibraryDependencyData> toImport,
     @NotNull ModifiableRootModel moduleRootModel,
     @NotNull LibraryTable moduleLibraryTable,
     @NotNull LibraryTable libraryTable,
     @NotNull Module module) {
   for (LibraryDependencyData dependencyData : toImport) {
     LibraryData libraryData = dependencyData.getTarget();
     if (libraryData.isUnresolved()) {
       continue;
     }
     switch (dependencyData.getLevel()) {
       case MODULE:
         @SuppressWarnings("ConstantConditions")
         Library moduleLib = moduleLibraryTable.createLibrary(dependencyData.getName());
         Library.ModifiableModel libModel = moduleLib.getModifiableModel();
         try {
           Map<OrderRootType, Collection<File>> files =
               myLibraryManager.prepareLibraryFiles(libraryData);
           myLibraryManager.registerPaths(files, libModel, dependencyData.getName());
         } finally {
           libModel.commit();
         }
         break;
       case PROJECT:
         final Library projectLib = libraryTable.getLibraryByName(dependencyData.getName());
         if (projectLib == null) {
           assert false;
           continue;
         }
         LibraryOrderEntry orderEntry = moduleRootModel.addLibraryEntry(projectLib);
         LOG.info(
             String.format(
                 "Adding library dependency '%s' to module '%s'",
                 projectLib.getName(), module.getName()));
         orderEntry.setExported(dependencyData.isExported());
         orderEntry.setScope(dependencyData.getScope());
         LOG.info(
             String.format(
                 "Configuring library dependency '%s' of module '%s' to be%s exported and have scope %s",
                 projectLib.getName(),
                 module.getName(),
                 dependencyData.isExported() ? " not" : "",
                 dependencyData.getScope()));
     }
   }
 }