private void attachLibraries( @NotNull Collection<VirtualFile> libraryRoots, Set<VirtualFile> exclusions) { ApplicationManager.getApplication().assertIsDispatchThread(); if (!libraryRoots.isEmpty()) { ApplicationManager.getApplication() .runWriteAction( () -> { ModuleRootManager model = ModuleRootManager.getInstance(myModule); LibraryOrderEntry goLibraryEntry = OrderEntryUtil.findLibraryOrderEntry(model, getLibraryName()); if (goLibraryEntry != null && goLibraryEntry.isValid()) { Library library = goLibraryEntry.getLibrary(); if (library != null && !((LibraryEx) library).isDisposed()) { fillLibrary(library, libraryRoots, exclusions); } } else { LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myModule.getProject()); Library library = libraryTable.createLibrary(getLibraryName()); fillLibrary(library, libraryRoots, exclusions); ModuleRootModificationUtil.addDependency(myModule, library); } }); showNotification(myModule.getProject()); } else { removeLibraryIfNeeded(); } }
public static void addDependency(Module module, Library library) { addDependency(module, library, DependencyScope.COMPILE, false); }
public static void addDependency(final Module from, final Module to) { addDependency(from, to, DependencyScope.COMPILE, false); }
protected Module addDependentModule() { Module module = addModule("dependent"); ModuleRootModificationUtil.addDependency(module, myModule); return module; }