Library (final Project project, final @Nullable Module module, final String name, final DependencyScope scope, final VirtualFile[] jars) { return WriteAction.computeAndWait(() -> { final Library library = LibraryTablesRegistrar.getInstance().getLibraryTable(project).createLibrary(name); final Library.ModifiableModel libraryModel = library.getModifiableModel(); for (VirtualFile jar : jars) { libraryModel.addRoot(jar, OrderRootType.CLASSES); } libraryModel.commit(); if (module != null) { ModuleRootModificationUtil.addDependency(module, library, scope, false); } return library; }); }