private static void setLibraryEntryExported(
     ModifiableRootModel rootModel, boolean exported, Library library) {
   for (OrderEntry orderEntry : rootModel.getOrderEntries()) {
     if (orderEntry instanceof LibraryOrderEntry
         && ((LibraryOrderEntry) orderEntry).isModuleLevel()
         && Comparing.equal(((LibraryOrderEntry) orderEntry).getLibrary(), library)) {
       ((LibraryOrderEntry) orderEntry).setExported(exported);
       break;
     }
   }
 }
 private static void setLibraryScope(
     @NotNull LibraryOrderEntry orderEntry,
     @NotNull Library lib,
     @NotNull Module module,
     @NotNull LibraryDependencyData dependencyData) {
   orderEntry.setExported(dependencyData.isExported());
   orderEntry.setScope(dependencyData.getScope());
   LOG.debug(
       String.format(
           "Configuring library '%s' of module '%s' to be%s exported and have scope %s",
           lib,
           module.getName(),
           dependencyData.isExported() ? " not" : "",
           dependencyData.getScope()));
 }
 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()));
     }
   }
 }