void (@NotNull ModifiableRootModel model, String mavenCoordinates, boolean includeTransitiveDependencies, DependencyScope dependencyScope, List<RemoteRepositoryDescription> additionalRepositories) { List<RemoteRepositoryDescription> remoteRepositoryDescriptions = ContainerUtil.concat(getRemoteRepositoryDescriptions(), additionalRepositories); RepositoryLibraryProperties libraryProperties = new RepositoryLibraryProperties(mavenCoordinates, includeTransitiveDependencies); Collection<OrderRoot> roots = JarRepositoryManager.loadDependenciesModal(model.getProject(), libraryProperties, false, false, null, remoteRepositoryDescriptions); LibraryTable.ModifiableModel tableModel = model.getModuleLibraryTable().getModifiableModel(); Library library = tableModel.createLibrary(mavenCoordinates, RepositoryLibraryType.REPOSITORY_LIBRARY_KIND); Library.ModifiableModel libraryModel = library.getModifiableModel(); if (roots.isEmpty()) { throw new IllegalStateException(String.format("No roots for '%s'", mavenCoordinates)); } for (OrderRoot root : roots) { libraryModel.addRoot(root.getFile(), root.getType()); } ((LibraryEx.ModifiableModelEx) libraryModel).setProperties(libraryProperties); LibraryOrderEntry libraryOrderEntry = model.findLibraryOrderEntry(library); if (libraryOrderEntry == null) { throw new IllegalStateException("Unable to find registered library " + mavenCoordinates); } libraryOrderEntry.setScope(dependencyScope); libraryModel.commit(); tableModel.commit(); }