Package com.intellij.openapi.roots.libraries

Examples of com.intellij.openapi.roots.libraries.Library


    public static Library findLibrary(final Project pProject, final Artifact pDependency) {
        final LibraryTablesRegistrar libTableMgr = LibraryTablesRegistrar.getInstance();
        final LibraryTable libTable = libTableMgr.getLibraryTable(pProject);

        String libName = pDependency.toString();
        Library lib = libTable.getLibraryByName(libName);
        if (lib == null) {
            String type = pDependency.getType();
            if (type == null || type.trim().length() == 0)
                type = "jar";
View Full Code Here


        final Set<VirtualFile> files = new HashSet<VirtualFile>();
        final OrderEntry[] entries = model.getOrderEntries();
        for (OrderEntry entry : entries) {
            if (entry instanceof LibraryOrderEntry) {
                final LibraryOrderEntry libEntry = (LibraryOrderEntry) entry;
                final Library lib = libEntry.getLibrary();
                if (lib == null)
                    Collections.addAll(files, libEntry.getFiles(OrderRootType.CLASSES));
                else
                    Collections.addAll(files, lib.getFiles(OrderRootType.CLASSES));
            }
            else if (pIncludeJdk || !(entry instanceof JdkOrderEntry))
                Collections.addAll(files, entry.getFiles(OrderRootType.CLASSES));
        }
View Full Code Here

            //
            //if a library with the name of the dependency already exists,
            //use it. Otherwise, create a new one
            //
            final Artifact artifact = problem.getArtifact();
            Library lib = IDEUtils.findLibrary(project, artifact);
            if (lib == null)
                lib = libTable.createLibrary(artifact.toString());

            //
            //get the library's modifiable model
            //
            final Library.ModifiableModel model = lib.getModifiableModel();

            //
            //calculate the dependency's location in the local repository
            //
            final PomRepoManager repoMgr = PomRepoManager.getInstance(project);
View Full Code Here

            final OrderEntry[] entries = model.getOrderEntries();
            for (OrderEntry entry : entries) {
                if (entry instanceof LibraryOrderEntry) {
                    final LibraryOrderEntry libEntry = (LibraryOrderEntry) entry;
                    final Library lib = libEntry.getLibrary();

                    final VirtualFile[] files;
                    if (lib == null)
                        files = libEntry.getFiles(OrderRootType.CLASSES);
                    else
                        files = lib.getFiles(OrderRootType.CLASSES);

                    for (VirtualFile file : files)
                        if (file.equals(problem.getFile()))
                            model.removeOrderEntry(libEntry);
                }
View Full Code Here

        for (Module module : findModulesWithLibrary(modules, libraryName)) {

          ModifiableRootModel moduleRootManager = ModuleRootManager.getInstance(module).getModifiableModel();
          LibraryTable libraryTable = moduleRootManager.getModuleLibraryTable();

          Library library = libraryTable.getLibraryByName(libraryName);
          if (library != null) libraryTable.removeLibrary(library);
          moduleRootManager.commit();

        }
      }
View Full Code Here

        for (Module module : findModulesWithoutLibrary(modules, libraryName)) {

          ModifiableRootModel moduleRootManager = ModuleRootManager.getInstance(module).getModifiableModel();
          LibraryTable libraryTable = moduleRootManager.getModuleLibraryTable();

          Library library = libraryTable.createLibrary(libraryName);
          Library.ModifiableModel modifiableLibrary = library.getModifiableModel();
          for (Pair<String, OrderRootType> pathAndType : paths) {
            modifiableLibrary.addRoot(pathAndType.first, pathAndType.second);
          }
          modifiableLibrary.commit();
View Full Code Here

    });
  }

  private static boolean dependsOn(String libraryName, Module module) {
    ModifiableRootModel moduleRootManager = ModuleRootManager.getInstance(module).getModifiableModel();
    Library library = moduleRootManager.getModuleLibraryTable().getLibraryByName(libraryName);
    return library != null;
  }
View Full Code Here

        return libraryModels.get(libraryName);
    }

    private Library getIvyIdeaLibrary(ModifiableRootModel modifiableRootModel, final String libraryName) {
        final LibraryTable libraryTable = modifiableRootModel.getModuleLibraryTable();
        final Library library = libraryTable.getLibraryByName(libraryName);
        if (library == null) {
            LOGGER.info("Internal library not found for module " + modifiableRootModel.getModule().getModuleFilePath() + ", creating with name " + libraryName + "...");
            return libraryTable.createLibrary(libraryName);
        }
        return library;
View Full Code Here

    }
    return false;
  }

  private static boolean findExistingLibrary(@NotNull String libraryName, @NotNull List<File> result, String... urls) {
    Library library = ApplicationLibraryTable.getApplicationTable().getLibraryByName(libraryName);
    return library != null && collectFiles(result, library.getUrls(OrderRootType.CLASSES), urls);
  }
View Full Code Here

  private static void createOrUpdateLibrary(@NotNull final String libraryName,
                                            @NotNull final List<Pair<VirtualFile, DownloadableFileDescription>> pairs) {
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      @Override
      public void run() {
        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();
      }
View Full Code Here

TOP

Related Classes of com.intellij.openapi.roots.libraries.Library

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.