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(); } }
private void assertLibrary(@NotNull Collection<String> libUrls, String... exclusionUrls) { UIUtil.dispatchAllInvocationEvents(); GoModuleLibrariesInitializer initializer = myModule.getComponent(GoModuleLibrariesInitializer.class); ModuleRootManager model = ModuleRootManager.getInstance(myModule); LibraryOrderEntry libraryOrderEntry = OrderEntryUtil.findLibraryOrderEntry(model, initializer.getLibraryName()); if (libUrls.isEmpty()) { assertNull(libraryOrderEntry); return; } LibraryEx library = (LibraryEx)libraryOrderEntry.getLibrary(); assertNotNull(library); assertSameElements(Arrays.asList(library.getUrls(OrderRootType.CLASSES)), libUrls); assertSameElements(library.getExcludedRootUrls(), exclusionUrls); }
public void testAppEngine_defaultManagedLibrariesSelected() { AppEngineStandardLibraryPanel libraryPanel = new AppEngineStandardLibraryPanel(true /*enabled*/); LibraryEx library = mock(LibraryEx.class); when(library.getTable()).thenReturn(ProjectLibraryTable.getInstance(myModule.getProject())); when(library.getExcludedRoots()).thenReturn(new VirtualFile[0]); when(library.getName()).thenReturn("javax.servlet:servlet-api:2.5"); setupAppEngine(libraryPanel, library); addSupport(); assertNull(FacetManager.getInstance(myModule).getFacetByType(WebFacet.ID)); final String moduleName = myModule.getName(); ArtifactsTestUtil.assertLayout( myProject, moduleName, "<root>\n" + " WEB-INF/\n" + " classes/\n" + " module:" + moduleName + "\n" + " lib/\n" + " lib:javax.servlet:servlet-api:2.5(project)\n"); }
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 ballerinaLibraryEntry = OrderEntryUtil.findLibraryOrderEntry(model, getLibraryName()); if (ballerinaLibraryEntry != null && ballerinaLibraryEntry.isValid()) { Library library = ballerinaLibraryEntry.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(); } }