private static void fillLibrary(@NotNull Library library, @NotNull Collection<VirtualFile> libraryRoots, Set<VirtualFile> exclusions) { ApplicationManager.getApplication().assertWriteAccessAllowed(); Library.ModifiableModel libraryModel = library.getModifiableModel(); for (String root : libraryModel.getUrls(OrderRootType.CLASSES)) { libraryModel.removeRoot(root, OrderRootType.CLASSES); } for (String root : libraryModel.getUrls(OrderRootType.SOURCES)) { libraryModel.removeRoot(root, OrderRootType.SOURCES); } for (VirtualFile libraryRoot : libraryRoots) { libraryModel.addRoot(libraryRoot, OrderRootType.CLASSES); // in order to consider GOPATH as library and show it in Ext. Libraries libraryModel.addRoot(libraryRoot, OrderRootType.SOURCES); // in order to find usages inside GOPATH } for (VirtualFile root : exclusions) { ((LibraryEx.ModifiableModelEx)libraryModel).addExcludedRoot(root.getUrl()); } libraryModel.commit(); }
private static void fillLibrary(@NotNull Library library, @NotNull Collection<VirtualFile> libraryRoots, Set<VirtualFile> exclusions) { ApplicationManager.getApplication().assertWriteAccessAllowed(); Library.ModifiableModel libraryModel = library.getModifiableModel(); for (String root : libraryModel.getUrls(OrderRootType.CLASSES)) { libraryModel.removeRoot(root, OrderRootType.CLASSES); } for (String root : libraryModel.getUrls(OrderRootType.SOURCES)) { libraryModel.removeRoot(root, OrderRootType.SOURCES); } for (VirtualFile libraryRoot : libraryRoots) { // in order to consider BALLERINA_REPOSITORY as library and show it in Ext. Libraries libraryModel.addRoot(libraryRoot, OrderRootType.CLASSES); // In order to find usages inside BALLERINA_REPOSITORY. libraryModel.addRoot(libraryRoot, OrderRootType.SOURCES); } for (VirtualFile root : exclusions) { ((LibraryEx.ModifiableModelEx) libraryModel).addExcludedRoot(root.getUrl()); } libraryModel.commit(); }
Library lib = get != null ? get : table.createLibrary(GoSmallIDEsSdkService.LIBRARY_NAME); Library.ModifiableModel libraryModel = lib.getModifiableModel(); String libUrl = ArrayUtil.getFirstElement(lib.getUrls(OrderRootType.CLASSES)); if (libUrl != null) {
Library lib = get != null ? get : table.createLibrary(BallerinaSmallIDEsSdkService.LIBRARY_NAME); Library.ModifiableModel libraryModel = lib.getModifiableModel(); String libUrl = ArrayUtil.getFirstElement(lib.getUrls(OrderRootType.CLASSES)); if (libUrl != null) {
private static void createOrUpdateLibrary(@NotNull String libraryName, @NotNull List<Pair<VirtualFile, DownloadableFileDescription>> pairs) { ApplicationManager.getApplication().assertWriteAccessAllowed(); Library library = ApplicationLibraryTable.getApplicationTable().getLibraryByName(libraryName); if (library == null) { LibraryTable.ModifiableModel modifiableModel = ApplicationLibraryTable.getApplicationTable().getModifiableModel(); library = modifiableModel.createLibrary(libraryName); modifiableModel.commit(); } Library.ModifiableModel modifiableModel = library.getModifiableModel(); for (Pair<VirtualFile, DownloadableFileDescription> pair : pairs) { modifiableModel.addRoot(pair.first, OrderRootType.CLASSES); } modifiableModel.commit(); }
Library.ModifiableModel libraryModel = globalLibrary.getModifiableModel(); libraryModel.addRoot(sourceRoot, ORDER_ROOT_TYPE); libraryModel.commit(); .findAny(); if (!libraryFile.isPresent()) { Library.ModifiableModel libraryModel = globalLibrary.getModifiableModel(); clear(libraryModel); libraryModel.addRoot(sourceRoot, ORDER_ROOT_TYPE);
final String sourceLibraryPath = libInfo.second; Library library = libraryTable.createLibrary(); Library.ModifiableModel modifiableModel = library.getModifiableModel(); modifiableModel.addRoot(getUrlByPath(moduleLibraryPath), OrderRootType.CLASSES); if (sourceLibraryPath != null) {
@Override public void run() { final LibraryTable table = LibraryTablesRegistrar.getInstance() .getLibraryTableByLevel( LibraryTablesRegistrar.APPLICATION_LEVEL, myModule.getProject()); assert table != null; final LibraryTable.ModifiableModel tableModel = table.getModifiableModel(); final Library library = tableModel.createLibrary("endpoints-lib"); final Library.ModifiableModel libraryModel = library.getModifiableModel(); libraryModel.addJarDirectory(pluginsDir, true); libraryModel.commit(); tableModel.commit(); ModifiableRootModel rootModel = ModuleRootManager.getInstance(myModule).getModifiableModel(); Library jar = table.getLibraries()[0]; rootModel.addLibraryEntry(jar); // Endpoint is the only jar added rootModel.commit(); } });