23

I want to run a command

mvn clean dbmaintain:updateDatabase
  1. How can I run this command for a project opened in IntelliJ IDEA 12?

  2. If I will run this command, will it automatically run the scripts commands on my db server that's mentioned in my pom.xml file or jdbc.properties file?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
coure2011
  • 40,286
  • 83
  • 216
  • 349

2 Answers2

47

If your project has been detected by IntelliJ as a Maven project, then you should take a look at the Maven project window, on the right side. Your project should show up as a node, with a Lifecycle subnode. If you expand it, you will see the available goals, including clean.

Right-click on this goal, choose Create yourProject[clean] and in the popup window you will be able to add extra goals to run, including dbmaintain:updateDatabase. Running this configuration will be exactly the same as running the command from an external command prompt.

If your project has not been detected as a Maven project, try reimporting it by opening the root pom.xml using File > Open. IntelliJ will ask if you want to reopen the project using the Maven structure.

Bastien Jansen
  • 8,756
  • 2
  • 35
  • 53
  • After right-clicking on subnode clean, in popup in command: box I typed clean dbmaintain:updateDatabase and then clicked Apply. Then I run it, now when I right-click on that subnode again, It gave me no option of Create yourProject[clean]... is it configured only once? is it ran correctly? – coure2011 Mar 19 '13 at 15:23
  • I don't have this problem. Are you right-clicking on `clean` or on the `Lifecycle` folder? – Bastien Jansen Mar 19 '13 at 15:38
  • NOTE: Your new `clean` option will show up in the Maven window under `Maven | Run Configurations`, and will be something like `YOUR-PROJECT [clean]` – Brad Parks Sep 24 '19 at 11:57
2

Adding multiple goals in intellij is possible like below

Step0 :

Right click maven project in the maven dialog of the windows as described below...

Step1 :

enter image description here

Step2 : enter image description here

Ram Ghadiyaram
  • 28,239
  • 13
  • 95
  • 121