Maven - reading effective POM via Maven library
Hi everybody,
in order to get the right configurations for my plugin I need to read from the effective POM of the working project.
I found the class MavenShowEffectivePom under org.jetbrains.idea.maven.project.actions which seems to do exactly what I need.
I tried to implement the code they use and I've ran into a problem I can't seem to solve.
In order to get the mavenProject they use:
MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
MavenProject mavenProject = manager.findProject(file);
I've implemented those lines and made sure to generate project and file exactly as they do it:
public void actionPerformed(@NotNull AnActionEvent event) {
Project project = MavenActionUtil.getProject(event.getDataContext());
if(project != null) {
VirtualFile file = findPomXml(event.getDataContext());
if(file != null) {
if(MavenServerManager.getInstance().isUseMaven2()) {
showUnsupportedNotification(project);
} else {
actionPerformed(project, file);
}
}
}
}
Now when I try to build my project it throws this error:
Error:(26, 44) java: cannot access org.jetbrains.idea.maven.model.MavenArtifact
class file for org.jetbrains.idea.maven.model.MavenArtifact not found
Which points to manager.findProject(file)
In addition to this it also throws this error:
Error:(36, 66) java: cannot access org.jetbrains.idea.maven.model.MavenId
class file for org.jetbrains.idea.maven.model.MavenId not found
at:
String fileName = mavenProject.getMavenId() + "-effective-pom.xml";
This is everything in the stacktrace. I don't understand why it even needs to access the org.jetbrains.idea.maven.model part since the
manager.findProject(file);
is from the org.jetbrains.idea.maven.project directory which does exist!
Can anybody help me or point me into the right direction?
Please sign in to leave a comment.
When I got the first error, I had to explicitly add maven.jar from my target IDEA distribution ($IDEA_HOME/plugins/maven/lib/maven.jar) into my build classpath.