How to trigger Maven or Gradle tasks from a plugin

Hi Community,

I want to know if there is a possibility to trigger a Maven or Gradle tasks or access the cmd to execute a command for this.

Markus

6 comments

For visibility I shall post my original answer from the previous thread - http://devnet.jetbrains.com/message/5490144#5490144

---

Hi Markus,

I'm not entirely sure how to do this currently;

But within IntelliJ there are the concept of services (http://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+Plugin+Structure#IntelliJIDEAPluginStructure-PluginServices) which allows a plugin component to be loaded on demand.
And I can also see from the Maven plugin.xml file that it exposes some services (https://github.com/JetBrains/intellij-community/blob/master/plugins/maven/src/main/resources/META-INF/plugin.xml)

That might be worth checking out.


Alan

0

After some try and error I don't really get a solution for this problem.
I can't get the same services as in the Maven plugin.xml into my project.

Markus

0

Have you added the library to your classpath?

If you still can't get it that way, i'm afraid someone else will have to confirm how to do it :)

Cheers

0

Which library do you mean?

Sorry but I'm just a newbie to plugin development :)
I think it would be easier to execute a cmd command but I don't even know how to do that :^O

Markus

0

You must add all JARs from plugins ($IDEA_HOME$/plugins/...) to your IntelliJ Platform SDK in order to use components provided by them.

0

Thanks a lot,

it works!
I use the MavenRunner to execute a Maven task and it runs fine.

Markus

- Edit: I found an easier way. I execute a cmd command with Runtime.exec(cmd) and specify a Maven command.

0

Please sign in to leave a comment.