private static Collection<? extends PackagingSourceItem> createClasspathItems(
      ArtifactEditorContext editorContext, Artifact artifact, @NotNull Module module) {
    final List<PackagingSourceItem> items = new ArrayList<PackagingSourceItem>();
    final ModuleRootModel rootModel = editorContext.getModulesProvider().getRootModel(module);
    List<Library> libraries = new ArrayList<Library>();
    for (OrderEntry orderEntry : rootModel.getOrderEntries()) {
      if (orderEntry instanceof LibraryOrderEntry) {
        final LibraryOrderEntry libraryEntry = (LibraryOrderEntry) orderEntry;
        final Library library = libraryEntry.getLibrary();
        final DependencyScope scope = libraryEntry.getScope();
        if (library != null && scope.isForProductionRuntime()) {
          libraries.add(library);
        }
      }
    }

    for (Module toAdd : getNotAddedModules(editorContext, artifact, module)) {
      items.add(new ModuleOutputSourceItem(toAdd));
    }

    for (Library library : getNotAddedLibraries(editorContext, artifact, libraries)) {
      items.add(new LibrarySourceItem(library));
    }
    return items;
  }
コード例 #2
0
  public static void setStorageType(@NotNull ModuleRootModel model, @NotNull String storageId) {
    Module module = model.getModule();
    String oldStorageType = ClassPathStorageUtil.getStorageType(module);
    if (oldStorageType.equals(storageId)) {
      return;
    }

    ClasspathStorageProvider provider = getProvider(oldStorageType);
    if (provider != null) {
      provider.detach(module);
    }

    provider = getProvider(storageId);
    if (provider == null) {
      module.clearOption(JpsProjectLoader.CLASSPATH_ATTRIBUTE);
      module.clearOption(JpsProjectLoader.CLASSPATH_DIR_ATTRIBUTE);
    } else {
      module.setOption(JpsProjectLoader.CLASSPATH_ATTRIBUTE, storageId);
      String root = provider.getContentRoot(model);
      if (root == null) {
        module.clearOption(JpsProjectLoader.CLASSPATH_DIR_ATTRIBUTE);
      } else {
        module.setOption(JpsProjectLoader.CLASSPATH_DIR_ATTRIBUTE, root);
      }
    }
  }
コード例 #3
0
 @Nullable
 private static ContentEntry findContentEntry(ModuleRootModel rootModel, VirtualFile file) {
   return ContainerUtil.find(
       rootModel.getContentEntries(),
       object -> {
         VirtualFile entryRoot = object.getFile();
         return entryRoot != null && VfsUtilCore.isAncestor(entryRoot, file, false);
       });
 }
コード例 #4
0
 @Nullable
 private static ContentEntry findContentEntry(ModuleRootModel rootModel, final VirtualFile file) {
   return ContainerUtil.find(
       rootModel.getContentEntries(),
       new Condition<ContentEntry>() {
         @Override
         public boolean value(final ContentEntry object) {
           VirtualFile entryRoot = object.getFile();
           return entryRoot != null && VfsUtilCore.isAncestor(entryRoot, file, false);
         }
       });
 }