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


Java MavenProjectsManager.findProject方法代码示例

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


在下文中一共展示了MavenProjectsManager.findProject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: resolve

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
public static String resolve(String text, MavenDomProjectModel projectDom) {
  XmlElement element = projectDom.getXmlElement();
  if (element == null) return text;

  VirtualFile file = MavenDomUtil.getVirtualFile(element);
  if (file == null) return text;
  MavenProjectsManager manager = MavenProjectsManager.getInstance(projectDom.getManager().getProject());

  MavenProject mavenProject = manager.findProject(file);
  if (mavenProject == null) return text;

  StringBuilder res = new StringBuilder();
  try {
    doFilterText(PATTERN, manager, mavenProject, text, collectPropertiesFromDOM(mavenProject, projectDom), null, false, null, res);
  }
  catch (IOException e) {
    throw new RuntimeException(e); // never thrown
  }

  return res.toString();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:MavenPropertyResolver.java

示例5: getMavenProject

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
private MavenProject getMavenProject(Module module) { //RunConfiguration runConfiguration, Project project)
        final MavenProjectsManager instance = MavenProjectsManager.getInstance(module.getProject());
        return instance.findProject(module);
//
//        if (runConfiguration instanceof MuleConfiguration)
//        {
//            MuleConfiguration muleConfiguration = (MuleConfiguration) runConfiguration;
//            return instance.findProject(muleConfiguration.getModule());
//        }
//        return null;
    }
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:12,代码来源:MuleBeforeRunTasksProvider.java

示例6: getMavenProjects

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
public static List<MavenProject> getMavenProjects(DataContext context) {
  Project project = CommonDataKeys.PROJECT.getData(context);
  if (project == null) return Collections.emptyList();

  VirtualFile[] virtualFiles = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(context);
  if (virtualFiles == null || virtualFiles.length == 0) return Collections.emptyList();

  MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(project);
  if (!projectsManager.isMavenizedProject()) return Collections.emptyList();

  Set<MavenProject> res = new LinkedHashSet<MavenProject>();

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

  for (VirtualFile file : virtualFiles) {
    MavenProject mavenProject;

    if (file.isDirectory()) {
      VirtualFile contentRoot = fileIndex.getContentRootForFile(file);
      if (!file.equals(contentRoot)) return Collections.emptyList();

      Module module = fileIndex.getModuleForFile(file);
      if (module == null || !projectsManager.isMavenizedModule(module)) return Collections.emptyList();

      mavenProject = projectsManager.findProject(module);
    }
    else {
      mavenProject = projectsManager.findProject(file);
    }

    if (mavenProject == null) return Collections.emptyList();

    res.add(mavenProject);
  }

  return new ArrayList<MavenProject>(res);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:MavenActionUtil.java

示例7: getEditorTabTitle

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
public String getEditorTabTitle(Project project, VirtualFile file) {
  MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(project);
  if (!projectsManager.isMavenizedProject()) return null;

  MavenProject mavenProject = projectsManager.findProject(file);
  if (mavenProject == null) return null;

  return mavenProject.getMavenId().getArtifactId();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:MavenEditorTabTitleProvider.java

示例8: findProject

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
@Nullable
public static MavenProject findProject(@NotNull MavenDomProjectModel projectDom) {
  XmlElement element = projectDom.getXmlElement();
  if (element == null) return null;

  VirtualFile file = getVirtualFile(element);
  if (file == null) return null;
  MavenProjectsManager manager = MavenProjectsManager.getInstance(element.getProject());
  return manager.findProject(file);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:MavenDomUtil.java

示例9: isElementInsideManagedFile

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
private static boolean isElementInsideManagedFile(GenericDomValue value) {
  VirtualFile virtualFile = DomUtil.getFile(value).getVirtualFile();
  if (virtualFile == null) {
    return false;
  }

  MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(value.getManager().getProject());

  return projectsManager.findProject(virtualFile) != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:MavenModelInspection.java

示例10: findMavenProject

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
@Nullable
private static MavenProject findMavenProject(PsiElement element) {
  VirtualFile virtualFile = MavenDomUtil.getVirtualFile(element);
  if (virtualFile == null) return null;

  MavenProjectsManager manager = MavenProjectsManager.getInstance(element.getProject());
  return manager.findProject(virtualFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:MavenPropertyPsiReferenceProvider.java

示例11: applyFix

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
  GenericDomValue el = (GenericDomValue)myContext.getInvocationElement();
  MavenId id = MavenArtifactCoordinatesHelper.getId(myContext);

  MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
  MavenProject parentFile = manager.findProject(id);
  if (parentFile != null) {
    VirtualFile currentFile = myContext.getFile().getVirtualFile();
    el.setStringValue(MavenDomUtil.calcRelativePath(currentFile.getParent(), parentFile.getFile()));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:MavenParentRelativePathConverter.java

示例12: updateProjectFolders

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
public static void updateProjectFolders(final Project project, final boolean updateTargetFoldersOnly) {
  final MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
  final MavenImportingSettings settings = manager.getImportingSettings();

  AccessToken accessToken = WriteAction.start();
  try {
    List<ModifiableRootModel> rootModels = new ArrayList<ModifiableRootModel>();
    for (Module each : ModuleManager.getInstance(project).getModules()) {
      MavenProject mavenProject = manager.findProject(each);
      if (mavenProject == null) continue;

      MavenRootModelAdapter a = new MavenRootModelAdapter(mavenProject, each, new IdeModifiableModelsProviderImpl(project));
      new MavenFoldersImporter(mavenProject, settings, a).config(updateTargetFoldersOnly);

      ModifiableRootModel model = a.getRootModel();
      if (model.isChanged()) {
        rootModels.add(model);
      }
      else {
        model.dispose();
      }
    }

    if (!rootModels.isEmpty()) {
      ModifiableRootModel[] modelsArray = rootModels.toArray(new ModifiableRootModel[rootModels.size()]);
      if (modelsArray.length > 0) {
        ModifiableModelCommitter.multiCommit(modelsArray, ModuleManager.getInstance(modelsArray[0].getProject()).getModifiableModel());
      }
    }
  }
  finally {
    accessToken.finish();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:MavenFoldersImporter.java

示例13: isExistingProjectFile

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
private static boolean isExistingProjectFile(DataContext context, VirtualFile file) {
  MavenProjectsManager manager = MavenActionUtil.getProjectsManager(context);
  return manager != null && manager.findProject(file) != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:AddFileAsMavenProjectAction.java

示例14: dumpModulesPaths

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
private static File dumpModulesPaths(@NotNull Project project) throws IOException {
  ApplicationManager.getApplication().assertReadAccessAllowed();

  Properties res = new Properties();

  MavenProjectsManager manager = MavenProjectsManager.getInstance(project);

  for (Module module : ModuleManager.getInstance(project).getModules()) {
    if (manager.isMavenizedModule(module)) {
      MavenProject mavenProject = manager.findProject(module);
      if (mavenProject != null && !manager.isIgnored(mavenProject)) {
        res.setProperty(mavenProject.getMavenId().getGroupId()
                        + ':' + mavenProject.getMavenId().getArtifactId()
                        + ":pom"
                        + ':' + mavenProject.getMavenId().getVersion(),
                        mavenProject.getFile().getPath());

        res.setProperty(mavenProject.getMavenId().getGroupId()
                        + ':' + mavenProject.getMavenId().getArtifactId()
                        + ":test-jar"
                        + ':' + mavenProject.getMavenId().getVersion(),
                        mavenProject.getTestOutputDirectory());

        res.setProperty(mavenProject.getMavenId().getGroupId()
                        + ':' + mavenProject.getMavenId().getArtifactId()
                        + ':' + mavenProject.getPackaging()
                        + ':' + mavenProject.getMavenId().getVersion(),
                         mavenProject.getOutputDirectory());

      }
    }
  }

  File file = new File(PathManager.getSystemPath(), "Maven/idea-projects-state-" + project.getLocationHash() + ".properties");
  FileUtil.ensureExists(file.getParentFile());

  OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
  try {
    res.store(out, null);
  }
  finally {
    out.close();
  }

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

示例15: doResolveProperty

import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
@Nullable
private static String doResolveProperty(String propName,
                                        MavenProjectsManager projectsManager,
                                        MavenProject mavenProject,
                                        Properties additionalProperties) {
  boolean hasPrefix = false;
  String unprefixed = propName;

  if (propName.startsWith("pom.")) {
    unprefixed = propName.substring("pom.".length());
    hasPrefix = true;
  }
  else if (propName.startsWith("project.")) {
    unprefixed = propName.substring("project.".length());
    hasPrefix = true;
  }

  MavenProject selectedProject = mavenProject;

  while (unprefixed.startsWith("parent.")) {
    MavenId parentId = selectedProject.getParentId();
    if (parentId == null) return null;

    unprefixed = unprefixed.substring("parent.".length());

    if (unprefixed.equals("groupId")) {
      return parentId.getGroupId();
    }
    if (unprefixed.equals("artifactId")) {
      return parentId.getArtifactId();
    }
    if (unprefixed.equals("version")) {
      return parentId.getVersion();
    }

    selectedProject = projectsManager.findProject(parentId);
    if (selectedProject == null) return null;
  }

  if (unprefixed.equals("basedir") || (hasPrefix && mavenProject == selectedProject && unprefixed.equals("baseUri"))) {
    return selectedProject.getDirectory();
  }

  if ("java.home".equals(propName)) {
    String jreDir = MavenUtil.getModuleJreHome(projectsManager, mavenProject);
    if (jreDir != null) {
      return jreDir;
    }
  }

  if ("java.version".equals(propName)) {
    String javaVersion = MavenUtil.getModuleJavaVersion(projectsManager, mavenProject);
    if (javaVersion != null) {
      return javaVersion;
    }
  }

  String result;

  result = MavenUtil.getPropertiesFromMavenOpts().get(propName);
  if (result != null) return result;

  result = MavenServerUtil.collectSystemProperties().getProperty(propName);
  if (result != null) return result;

  result = selectedProject.getModelMap().get(unprefixed);
  if (result != null) return result;

  result = additionalProperties.getProperty(propName);
  if (result != null) return result;

  result = mavenProject.getProperties().getProperty(propName);
  if (result != null) return result;

  if ("settings.localRepository".equals(propName)) {
    return mavenProject.getLocalRepository().getAbsolutePath();
  }

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


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