Maven API/Goal invoking

Hi everybody!

 

We are writing an IntelliJ plugin that needs to invoke some maven goals and displays the results in IntelliJ.
Is it possible to invoke these maven goals in IntelliJ via an API call? I.e., is there a public API call in the bundled maven plug-in that runs a maven goal? Or is it at least possible to get the maven preferences (path, etc.) via an API call so that we can invoke maven using a system call?

2
4 comments
Official comment

You can try org.jetbrains.idea.maven.execution.MavenRunner, e.g.

MavenRunner runner = MavenRunner.getInstance(project);
MavenRunnerSettings settings = runner.getState().clone();
settings.getMavenProperties().put("interactiveMode", "false");
MavenRunnerParameters params = new MavenRunnerParameters();
params.setWorkingDirPath(workingDir.getPath());
params.setGoals(Collections.singletonList("org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate"));
runner.run(params, settings, () -> System.out.println("maven goal execution completed"));
Avatar
Permanently deleted user

Thanks a lot, I'm gonna give this a try!

0
Avatar
Permanently deleted user

This might be a silly question, but I can't seem to figure it out.

How do I go about importing "org.jetbrains.idea.maven.execution.MavenRunner" in my plugin project? 

 

0
Avatar
Permanently deleted user

I realized I can just include the lib from the intellij source of the directory you posted and it works.
Thanks a lot!

0

Please sign in to leave a comment.