I want to develop a idea intellij plugin just like "Maven Helper". I have to get the "MavenProject" object before I can do some biz logic. But I found the MavenProjectsManager is null (I use it in a maven project.)? Could someone give me some dev guide about this ? Thanks!
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(PlatformDataKeys.PROJECT);
VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
if (file == null || project == null) {
return;
}
String fileName = file.getName();
if (!fileName.endsWith(POM_XML)) {
return;
}
final MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(project);
}
Please make sure that you've added the jars of the Maven plugin to the classpath of your IntelliJ IDEA SDK and not as a separate library. Doing the latter will cause two copies of the Maven plugin classes to be loaded, which will lead to the problem that you're describing.