table.getModifiableModel().commit();
table.getModifiableModel().commit();
ApplicationManager.getApplication().runWriteAction(() -> { LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(); LibraryTable.ModifiableModel modifiableModel = libraryTable.getModifiableModel(); globalLibrary = libraryTable.getLibraryByName(LIB_NAME); if (globalLibrary == null) {
private static void removeOldProjectData(@NotNull final Project project) { final ModifiableModuleModel moduleModel = ModuleManager.getInstance(project).getModifiableModel(); for (Module module : moduleModel.getModules()) { moduleModel.disposeModule(module); } final LibraryTable.ModifiableModel libraryModel = ProjectLibraryTable.getInstance(project).getModifiableModel(); for (Library library : libraryModel.getLibraries()) { libraryModel.removeLibrary(library); } ApplicationManager.getApplication().runWriteAction(() -> { moduleModel.commit(); libraryModel.commit(); }); final GradleSupport gradleSupport = GradleSupport.getInstance(); if (gradleSupport != null) { gradleSupport.clearLinkedProjectSettings(project); } final AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(project); for (AntBuildFile antBuildFile : antConfiguration.getBuildFiles()) { antConfiguration.removeBuildFile(antBuildFile); } }
@Override public void run() { LibraryTable table = LibraryTablesRegistrar.getInstance() .getLibraryTableByLevel( LibraryTablesRegistrar.APPLICATION_LEVEL, myModule.getProject()); if (table != null) { LibraryTable.ModifiableModel tableModel = table.getModifiableModel(); Library library = tableModel.getLibraryByName("endpoints-lib"); if (library != null) { tableModel.removeLibrary(library); tableModel.commit(); } } } });
@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(); } });