当前位置: 首页>>代码示例>>Java>>正文


Java MavenProjectsManager类代码示例

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


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


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