use of org.jetbrains.idea.maven.project.MavenProjectsManager in project intellij-community by JetBrains.
the class MavenExternalParameters method dumpModulesPaths.
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() + ':' + mavenProject.getPackaging() + ':' + mavenProject.getMavenId().getVersion(), mavenProject.getOutputDirectory());
res.setProperty(mavenProject.getMavenId().getGroupId() + ':' + mavenProject.getMavenId().getArtifactId() + ":test-jar" + ':' + mavenProject.getMavenId().getVersion(), mavenProject.getTestOutputDirectory());
addArtifactFileMapping(res, mavenProject, "sources");
addArtifactFileMapping(res, mavenProject, "test-sources");
addArtifactFileMapping(res, mavenProject, "javadoc");
addArtifactFileMapping(res, mavenProject, "test-javadoc");
}
}
}
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;
}
use of org.jetbrains.idea.maven.project.MavenProjectsManager in project intellij-community by JetBrains.
the class MavenModelInspection method isElementInsideManagedFile.
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;
}
use of org.jetbrains.idea.maven.project.MavenProjectsManager in project intellij-community by JetBrains.
the class MavenDomUtil method findContainingMavenizedModule.
@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;
}
use of org.jetbrains.idea.maven.project.MavenProjectsManager in project intellij-community by JetBrains.
the class MavenDomUtil method findContainingProject.
@Nullable
public static MavenProject findContainingProject(@NotNull PsiElement element) {
VirtualFile file = getVirtualFile(element);
if (file == null)
return null;
MavenProjectsManager manager = MavenProjectsManager.getInstance(element.getProject());
return manager.findContainingProject(file);
}
use of org.jetbrains.idea.maven.project.MavenProjectsManager in project intellij-community by JetBrains.
the class MavenPropertyResolver method doFilterText.
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);
}
Aggregations