本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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()));
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}