我怎样才能获得maven的本地存储库在intellij idea插件开发中

时间:2018-03-27 06:00:30

标签: java maven intellij-idea intellij-plugin

我想在intellij idea插件开发中获得maven的本地存储库。

 @Override
public void actionPerformed(AnActionEvent e) {
    logger.info("begin generator");
    Project project = e.getProject();
    /*in here ,I want to get maven's local repository*/
    if(project ==null)
        return;
    PsiJavaFile file = UtpJunitGenUtil.getSelectedJavaFile(e.getDataContext());

Intellij Idea Settings

1 个答案:

答案 0 :(得分:1)

您需要在Maven插件上添加依赖项(有关添加插件依赖项的信息,请参阅here)并使用以下代码:

MavenProjectsManager m = MavenProjectsManager.getInstance(project);
File localRepository = m.getGeneralSettings().getEffectiveLocalRepository();