Java Code Examples for com.intellij.openapi.roots.ModifiableRootModel#getModuleLibraryTable()
The following examples show how to use
com.intellij.openapi.roots.ModifiableRootModel#getModuleLibraryTable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HaxelibClasspathUtils.java From intellij-haxe with Apache License 2.0 | 5 votes |
/** * Get the classpath for the given module. This does not include any * paths from projects or SDKs. * * @param module to look up haxelib for. * @return a (possibly empty) collection of classpaths. These are NOT * necessarily properly ordered, but they are unique. */ @NotNull public static HaxeClasspath getModuleClasspath(@NotNull Module module) { ModuleRootManager rootManager = ModuleRootManager.getInstance(module); if (null == rootManager) return HaxeClasspath.EMPTY_CLASSPATH; ModifiableRootModel rootModel = rootManager.getModifiableModel(); LibraryTable libraryTable = rootModel.getModuleLibraryTable(); HaxeClasspath moduleClasspath = loadClasspathFrom(libraryTable); rootModel.dispose(); // MUST dispose of the model. return moduleClasspath; }
Example 2
Source File: ProjectFromSourcesBuilderImplModified.java From tmc-intellij with MIT License | 4 votes |
private static void setupRootModel( ProjectDescriptor projectDescriptor, final ModuleDescriptor descriptor, final ModifiableRootModel rootModel, final Map<LibraryDescriptor, Library> projectLibs) { final CompilerModuleExtension compilerModuleExtension = rootModel.getModuleExtension(CompilerModuleExtension.class); compilerModuleExtension.setExcludeOutput(true); rootModel.inheritSdk(); //Module root model seems to store .iml files root dependencies. (src, test, lib) logger.info("Starting setupRootModel in ProjectFromSourcesBuilderImplModified"); final Set<File> contentRoots = descriptor.getContentRoots(); for (File contentRoot : contentRoots) { final LocalFileSystem lfs = LocalFileSystem.getInstance(); VirtualFile moduleContentRoot = lfs.refreshAndFindFileByPath( FileUtil.toSystemIndependentName(contentRoot.getPath())); if (moduleContentRoot != null) { final ContentEntry contentEntry = rootModel.addContentEntry(moduleContentRoot); final Collection<DetectedSourceRoot> sourceRoots = descriptor.getSourceRoots(contentRoot); for (DetectedSourceRoot srcRoot : sourceRoots) { final String srcpath = FileUtil.toSystemIndependentName(srcRoot.getDirectory().getPath()); final VirtualFile sourceRoot = lfs.refreshAndFindFileByPath(srcpath); if (sourceRoot != null) { contentEntry.addSourceFolder( sourceRoot, shouldBeTestRoot(srcRoot.getDirectory()), getPackagePrefix(srcRoot)); } } } } logger.info("Inherits compiler output path from project"); compilerModuleExtension.inheritCompilerOutputPath(true); logger.info("Starting to create module level libraries"); final LibraryTable moduleLibraryTable = rootModel.getModuleLibraryTable(); for (LibraryDescriptor libDescriptor : ModuleInsight.getLibraryDependencies( descriptor, projectDescriptor.getLibraries())) { final Library projectLib = projectLibs.get(libDescriptor); if (projectLib != null) { rootModel.addLibraryEntry(projectLib); } else { // add as module library final Collection<File> jars = libDescriptor.getJars(); for (File file : jars) { Library library = moduleLibraryTable.createLibrary(); Library.ModifiableModel modifiableModel = library.getModifiableModel(); modifiableModel.addRoot( VfsUtil.getUrlForLibraryRoot(file), OrderRootType.CLASSES); modifiableModel.commit(); } } } logger.info("Ending setupRootModel in ProjectFromSourcesBuilderImplModified"); }
Example 3
Source File: CMakeWorkspaceOverride.java From intellij with Apache License 2.0 | 4 votes |
private static boolean areLibrariesAndRootsModifiedByCMake(ModifiableRootModel modifiableModel) { LibraryTable table = modifiableModel.getModuleLibraryTable(); return table.getLibraryByName("Header Search Paths") != null; }
Example 4
Source File: GaugeLibHelper.java From Intellij-Plugin with Apache License 2.0 | 4 votes |
private void updateGaugeJavaLibIfNeeded(ModifiableRootModel model) { LibraryTable libraryTable = model.getModuleLibraryTable(); Library library = libraryTable.getLibraryByName(GAUGE_LIB); ProjectLib latestGaugeLib = gaugeLib(model.getModule()); updateLibrary(library, latestGaugeLib); }