Build project before own action not working


In a student project we have to write a plugin for IntelliJ for running second party tests from within the IDE. For that we need an action that rebuilds the whole project and after that runs the test. For testing purposes we wanted to display a MessageDialog after the rebuild is complete but for some reason the building procedure starts always after we close the MessageDialog. Can anybody give us a hint what we are doing wrong? Here is our take on this:

public class OurAction extends AnAction {

public void actionPerformed(@NotNull AnActionEvent e) {

ActionManager actionManager = ActionManager.getInstance();

AnAction rebuildProject = actionManager.getAction("CompileProject");

if(rebuildProject != null)
Messages.showMessageDialog(e.getProject(), "Compile Project Action not available", "Error", Messages.getInformationIcon());

// Should open after the rebuild is complete
Messages.showMessageDialog(e.getProject(), "Build complete", "Info", Messages.getInformationIcon());
// ...

Or is there another possibility to start the build-in 'Build Project' task that is a better solution in that case?

Thanks in advance for your help.

1 comment
Comment actions Permalink

Please use API via com.intellij.task.ProjectTaskManager to trigger build.


Please sign in to leave a comment.