• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MavenProjectsManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jetbrains.idea.maven.project.MavenProjectsManager的典型用法代码示例。如果您正苦于以下问题:Java MavenProjectsManager类的具体用法?Java MavenProjectsManager怎么用?Java MavenProjectsManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MavenProjectsManager类属于org.jetbrains.idea.maven.project包,在下文中一共展示了MavenProjectsManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: collectComponentsToScan

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
@Override
protected Components collectComponentsToScan(@Nullable DataNode<ProjectData> externalProject) {
    Components components = ComponentsFactory.create();
    // This set is used to make sure the artifacts added are unique
    Set<String> added = Sets.newHashSet();
    for (MavenProject mavenProject : MavenProjectsManager.getInstance(project).getProjects()) {
        for (MavenArtifactNode mavenArtifactNode : mavenProject.getDependencyTree()) {
            if (added.add(mavenArtifactNode.getArtifact().getDisplayStringForLibraryName())) {
                addArtifact(components, mavenArtifactNode.getArtifact());
                for (MavenArtifactNode artifactNode : mavenArtifactNode.getDependencies()) {
                    addArtifact(components, artifactNode.getArtifact());
                }
            }
        }
    }
    return components;
}
 
开发者ID:JFrogDev,项目名称:jfrog-idea-plugin,代码行数:18,代码来源:MavenScanManager.java


示例2: testOverrideAnnotationSources

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
public void testOverrideAnnotationSources() throws Exception {
  createStdProjectFolders();

  MavenProjectsManager.getInstance(myProject).getImportingSettings().setGeneratedSourcesFolder(
    MavenImportingSettings.GeneratedSourcesFolder.GENERATED_SOURCE_FOLDER);

  createProjectSubFile("target/generated-sources/com/A.java", "package com; class A {}");
  createProjectSubFile("target/generated-sources/annotations/com/B.java", "package com; class B {}");

  importProject("<groupId>test</groupId>" +
                "<artifactId>project</artifactId>" +
                "<version>1</version>");

  assertSources("project",
                "src/main/java",
                "target/generated-sources");
  assertResources("project", "src/main/resources");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:FoldersImportingTest.java


示例3: actionPerformed

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final DataContext context = e.getDataContext();

  MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
  if(projectsManager == null) return;

  List<VirtualFile> selectedFiles = MavenActionUtil.getMavenProjectsFiles(context);
  List<VirtualFile> removableFiles = new ArrayList<VirtualFile>();

  for (VirtualFile pomXml : selectedFiles) {
    if (projectsManager.isManagedFile(pomXml)) {
      removableFiles.add(pomXml);
    }
    else {
      notifyUserIfNeeded(context, projectsManager, selectedFiles, pomXml);
    }
  }
  projectsManager.removeManagedFiles(removableFiles);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:RemoveManagedFilesAction.java


示例4: notifyUserIfNeeded

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
private static void notifyUserIfNeeded(DataContext context,
                                       MavenProjectsManager projectsManager,
                                       List<VirtualFile> selectedFiles,
                                       VirtualFile pomXml) {
  MavenProject mavenProject = projectsManager.findProject(pomXml);
  assert mavenProject != null;

  MavenProject aggregator = projectsManager.findAggregator(mavenProject);
  while (aggregator != null && !projectsManager.isManagedFile(aggregator.getFile())) {
    aggregator = projectsManager.findAggregator(aggregator);
  }

  if (aggregator != null && !selectedFiles.contains(aggregator.getFile())) {
    notifyUser(context, mavenProject, aggregator);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:RemoveManagedFilesAction.java


示例5: update

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
@Override
public void update(AnActionEvent e) {
  super.update(e);
  if (!isAvailable(e)) return;

  final DataContext context = e.getDataContext();
  MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
  if(projectsManager == null) return;
  List<MavenProject> projects = MavenActionUtil.getMavenProjects(context);

  if (isIgnoredInSettings(projectsManager, projects)) {
    e.getPresentation().setText(ProjectBundle.message("maven.ignore.edit"));
  }
  else if (isIgnored(projectsManager, projects)) {
    e.getPresentation().setText(ProjectBundle.message("maven.unignore"));
  }
  else {
    e.getPresentation().setText(ProjectBundle.message("maven.ignore"));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ToggleIgnoredProjectsAction.java


示例6: isAvailable

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
@Override
protected boolean isAvailable(AnActionEvent e) {
  if (!super.isAvailable(e)) return false;

  final DataContext context = e.getDataContext();
  MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
  if(projectsManager == null) return false;
  List<MavenProject> projects = MavenActionUtil.getMavenProjects(context);

  if (projects == null || projects.isEmpty()) return false;

  int ignoredStatesCount = 0;
  int ignoredCount = 0;

  for (MavenProject each : projects) {
    if (projectsManager.getIgnoredState(each)) {
      ignoredStatesCount++;
    }
    if (projectsManager.isIgnored(each)) {
      ignoredCount++;
    }
  }

  return (ignoredCount == 0 || ignoredCount == projects.size()) &&
         (ignoredStatesCount == 0 || ignoredStatesCount == projects.size());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:ToggleIgnoredProjectsAction.java


示例7: getTargetState

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
@Nullable
private static MavenProfileKind getTargetState(@NotNull MavenProjectsManager projectsManager, Map<String, MavenProfileKind> profiles) {
  MavenExplicitProfiles explicitProfiles = projectsManager.getExplicitProfiles();
  MavenProfileKind targetState = null;
  // all profiles should target to the same state
  for (Map.Entry<String, MavenProfileKind> profile : profiles.entrySet()) {
    MavenProfileKind profileTargetState = getTargetState(profile, explicitProfiles);
    if (targetState == null) {
      targetState = profileTargetState;
    }
    else if (!targetState.equals(profileTargetState)) {
      targetState = null;
      break;
    }
  }
  return targetState;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ToggleProfileAction.java


示例8: findPomXml

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
@Nullable
private static VirtualFile findPomXml(@NotNull DataContext dataContext) {
  VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
  if (file == null) return null;

  if (file.isDirectory()) {
    file = file.findChild("pom.xml");
    if (file == null) return null;
  }

  MavenProjectsManager manager = MavenActionUtil.getProjectsManager(dataContext);
  if(manager == null) return null;
  MavenProject mavenProject = manager.findProject(file);
  if (mavenProject == null) return null;

  return file;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MavenShowEffectivePom.java


示例9: setupRootModel

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
  final Project project = rootModel.getProject();

  final VirtualFile root = createAndGetContentEntry();
  rootModel.addContentEntry(root);

  // todo this should be moved to generic ModuleBuilder
  if (myJdk != null){
    rootModel.setSdk(myJdk);
  } else {
    rootModel.inheritSdk();
  }

  MavenUtil.runWhenInitialized(project, new DumbAwareRunnable() {
    public void run() {
      if (myEnvironmentForm != null) {
        myEnvironmentForm.setData(MavenProjectsManager.getInstance(project).getGeneralSettings());
      }

      new MavenModuleBuilderHelper(myProjectId, myAggregatorProject, myParentProject, myInheritGroupId,
                                   myInheritVersion, myArchetype, myPropertiesToCreateByArtifact, "Create new Maven module").configure(project, root, false);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:MavenModuleBuilder.java


示例10: compile

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
private void compile(final CompileScope scope) {
  try {
    CompilerTester tester = new CompilerTester(myProject, Arrays.asList(scope.getAffectedModules()));
    UIUtil.invokeAndWaitIfNeeded(new Runnable() {
      @Override
      public void run() {
        new MavenResourceCompilerConfigurationGenerator(myProject, MavenProjectsManager.getInstance(myProject).getProjectsTreeForTests())
          .generateBuildConfiguration(false);
      }
    });
    try {
      List<CompilerMessage> messages = tester.make(scope);
      for (CompilerMessage message : messages) {
        if (message.getCategory() == CompilerMessageCategory.ERROR) {
          fail("Compilation failed with error: " + message.getMessage());
        }
      }
    }
    finally {
      tester.tearDown();
    }
  }
  catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:MavenCompilingTestCase.java


示例11: getMavenSettings

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
private static MavenGeneralSettings getMavenSettings(@NotNull final Project project, @NotNull MavenProgressIndicator indicator)
  throws MavenProcessCanceledException {
  MavenGeneralSettings settings;

  AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
  try {
    settings = project.isDisposed() ? null : MavenProjectsManager.getInstance(project).getGeneralSettings().clone();
  }
  finally {
    accessToken.finish();
  }

  if (settings == null) {
    // project was closed
    indicator.cancel();
    indicator.checkCanceled();
  }

  return settings;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MavenIndicesManager.java


示例12: testAddingExistingGeneratedSources3

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
public void testAddingExistingGeneratedSources3() throws Exception {
  createStdProjectFolders();

  MavenProjectsManager.getInstance(myProject).getImportingSettings().setGeneratedSourcesFolder(
    MavenImportingSettings.GeneratedSourcesFolder.SUBFOLDER);

  createProjectSubFile("target/generated-sources/com/A.java", "package com; class A {}");

  importProject("<groupId>test</groupId>" +
                "<artifactId>project</artifactId>" +
                "<version>1</version>");

  assertSources("project",
                "src/main/java",
                "target/generated-sources/com");
  assertResources("project", "src/main/resources");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:FoldersImportingTest.java


示例13: getMavenProject

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
@Nullable
public static MavenProject getMavenProject(DataContext context) {
  MavenProject result;
  final MavenProjectsManager manager = getProjectsManager(context);
  if(manager == null) return null;

  final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
  if (file != null) {
    result = manager.findProject(file);
    if (result != null) return result;
  }

  Module module = ExternalSystemActionUtil.getModule(context);
  if (module != null) {
    result = manager.findProject(module);
    if (result != null) return result;
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MavenActionUtil.java


示例14: getPhaseVariants

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
public static List<LookupElement> getPhaseVariants(MavenProjectsManager manager) {
  Set<String> goals = new HashSet<String>();
  goals.addAll(MavenConstants.PHASES);

  for (MavenProject mavenProject : manager.getProjects()) {
    for (MavenPlugin plugin : mavenProject.getPlugins()) {
      MavenPluginInfo pluginInfo = MavenArtifactUtil.readPluginInfo(manager.getLocalRepository(), plugin.getMavenId());
      if (pluginInfo != null) {
        for (MavenPluginInfo.Mojo mojo : pluginInfo.getMojos()) {
          goals.add(mojo.getDisplayName());
        }
      }
    }
  }

  List<LookupElement> res = new ArrayList<LookupElement>(goals.size());
  for (String goal : goals) {
    res.add(LookupElementBuilder.create(goal).withIcon(MavenIcons.Phase));
  }

  return res;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:MavenUtil.java


示例15: getStorageRoot

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
public static String getStorageRoot(String[] urls, Project project) {
  if (urls.length == 0) {
    return null;
  }
  final String localRepositoryPath =
    FileUtil.toSystemIndependentName(MavenProjectsManager.getInstance(project).getLocalRepository().getPath());
  List<String> roots = JBIterable.of(urls).transform(new Function<String, String>() {
    @Override
    public String fun(String urlWithPrefix) {
      String url = StringUtil.trimStart(urlWithPrefix, JarFileSystem.PROTOCOL_PREFIX);
      return url.startsWith(localRepositoryPath) ? null : FileUtil.toSystemDependentName(PathUtil.getParentPath(url));
    }
  }).toList();
  Map<String, Integer> counts = new HashMap<String, Integer>();
  for (String root : roots) {
    int count = counts.get(root) != null ? counts.get(root) : 0;
    counts.put(root, count + 1);
  }
  return Collections.max(counts.entrySet(), new Comparator<Map.Entry<String, Integer>>() {
    @Override
    public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
      return o1.getValue().compareTo(o2.getValue());
    }
  }).getKey();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:RepositoryUtils.java


示例16: MavenProjectsStructure

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
public MavenProjectsStructure(Project project,
                              MavenProjectsManager projectsManager,
                              MavenTasksManager tasksManager,
                              MavenShortcutsManager shortcutsManager,
                              MavenProjectsNavigator projectsNavigator,
                              SimpleTree tree) {
  myProject = project;
  myProjectsManager = projectsManager;
  myTasksManager = tasksManager;
  myShortcutsManager = shortcutsManager;
  myProjectsNavigator = projectsNavigator;

  configureTree(tree);

  myTreeBuilder = new SimpleTreeBuilder(tree, (DefaultTreeModel)tree.getModel(), this, null);
  Disposer.register(myProject, myTreeBuilder);

  myTreeBuilder.initRoot();
  myTreeBuilder.expand(myRoot, null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MavenProjectsStructure.java


示例17: createEmbedder

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
public MavenEmbedderWrapper createEmbedder(final Project project, final boolean alwaysOnline) {
  return new MavenEmbedderWrapper(this) {
    @NotNull
    @Override
    protected MavenServerEmbedder create() throws RemoteException {
      MavenServerSettings settings = convertSettings(MavenProjectsManager.getInstance(project).getGeneralSettings());
      if (alwaysOnline && settings.isOffline()) {
        settings = settings.clone();
        settings.setOffline(false);
      }

      settings.setProjectJdk(MavenUtil.getSdkPath(ProjectRootManager.getInstance(project).getProjectSdk()));

      return MavenServerManager.this.getOrCreateWrappee().createEmbedder(settings);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MavenServerManager.java


示例18: findContainingMavenizedModule

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
@Nullable
public static Module findContainingMavenizedModule(@NotNull PsiFile psiFile) {
  VirtualFile file = psiFile.getVirtualFile();
  if (file == null) return null;

  Project project = psiFile.getProject();

  MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
  if (!manager.isMavenizedProject()) return null;

  ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();

  Module module = index.getModuleForFile(file);
  if (module == null || !manager.isMavenizedModule(module)) return null;
  return module;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:MavenDomUtil.java


示例19: isFilteredResourceFile

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
public static boolean isFilteredResourceFile(PsiElement element) {
  PsiFile psiFile = element.getContainingFile();
  VirtualFile file = getVirtualFile(psiFile);
  if (file == null) return false;

  MavenProjectsManager manager = MavenProjectsManager.getInstance(psiFile.getProject());
  MavenProject mavenProject = manager.findContainingProject(file);
  if (mavenProject == null) return false;

  Set<VirtualFile> filteredRoots = getFilteredResourcesRoots(mavenProject);

  if (!filteredRoots.isEmpty()) {
    for (VirtualFile f = file.getParent(); f != null; f = f.getParent()) {
      if (filteredRoots.contains(f)) {
        return true;
      }
    }
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:MavenDomUtil.java


示例20: doFilterText

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入依赖的package包/类
public static void doFilterText(Module module,
                                String text,
                                Properties additionalProperties,
                                @Nullable String propertyEscapeString,
                                Appendable out) throws IOException {
  MavenProjectsManager manager = MavenProjectsManager.getInstance(module.getProject());
  MavenProject mavenProject = manager.findProject(module);
  if (mavenProject == null) {
    out.append(text);
    return;
  }

  Element pluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-resources-plugin");
  String escapeWindowsPathsStr = MavenJDOMUtil.findChildValueByPath(pluginConfiguration, "escapeWindowsPaths");
  boolean escapeWindowsPath = escapeWindowsPathsStr == null || Boolean.parseBoolean(escapeWindowsPathsStr);

  doFilterText(MavenFilteredPropertyPsiReferenceProvider.getDelimitersPattern(mavenProject),
               manager,
               mavenProject,
               text,
               additionalProperties,
               propertyEscapeString,
               escapeWindowsPath,
               null,
               out);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:MavenPropertyResolver.java



注:本文中的org.jetbrains.idea.maven.project.MavenProjectsManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IGenericClient类代码示例发布时间:2022-05-22
下一篇:
Java AclEntry类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap