Library (final @NotNull ModifiableRootModel rootModel, final @NotNull List<? super Library> addedLibraries, final @Nullable LibrariesContainer librariesContainer) { Library newLibrary = createLibrary(rootModel, librariesContainer); if (newLibrary != null) { addedLibraries.add(newLibrary); DependencyScope scope = LibraryDependencyScopeSuggester.getDefaultScope(newLibrary); if (getLibraryLevel() != LibrariesContainer.LibraryLevel.MODULE) { rootModel.addLibraryEntry(newLibrary).setScope(scope); } else { LibraryOrderEntry orderEntry = rootModel.findLibraryOrderEntry(newLibrary); assert orderEntry != null; orderEntry.setScope(scope); } } if (mySelectedLibrary != null) { addedLibraries.add(mySelectedLibrary); rootModel.addLibraryEntry(mySelectedLibrary).setScope(LibraryDependencyScopeSuggester.getDefaultScope(mySelectedLibrary)); } if (myLibraryProvider != null) { Library library = myLibraryProvider.createLibrary(myLibraryDescription.getSuitableLibraryKinds()); addedLibraries.add(library); rootModel.addLibraryEntry(library).setScope(LibraryDependencyScopeSuggester.getDefaultScope(library)); } return newLibrary; }