Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA: Run Batch script before and after Run/Debug Configuration

Background:

I have a Run config that runs a maven build. I already have a Context Path set up to look at the Target Directory of the Build directory, so I don't have to manually copy the war file over every time I run a build.

What I would like is for my build config to automatically kill the running tomcat process, run the build, and (if successfull) restart tomcat.

Problem:

I'd like to simply call the start/stop tomcat batch files before and after the build, but I've hit two snags:

  • In the Build Config->Before Launch section, there's no option to execute a batch script
  • There doesn't seem to be an "After build" section to complete Phase 2

Is there some way of enabling these options for my current build configuration (via a plugin or similar)?

-OR-

Is it possible to have build configurations run in sequence (one after the other) and is there a plugin or something to create a batch script build configuration?

like image 724
Robotnik Avatar asked Jun 15 '12 05:06

Robotnik


1 Answers

There is no way to run batch script directly in IDEA and it's also not possible to make a sequence of actions before run in IDEA 11.

In IDEA 12 it will be possible to specify multiple actions to perform before run, this way you can create a Maven goal that will restart Tomcat (by running batch script or some other way) and in Before Launch list specify 2 actions: kill running Tomcat process (which can be another Maven goal, another Run configuration or Ant task) and run the build (Maven goal). Here is how this UI looks like in IDEA 12:

Before Launch

When you run this configuration, it will kill Tomcat, perform the build and restart Tomcat.

It should also work if you chain multiple Run configurations with the Run Another Configuration Before Launch step.

IDEA 12 is planned for the end of 2012, but first EAP versions will be available in several weeks.


Another solution would be to use a single Maven goal with Mojo Executor or Ant task that will perform all the 3 actions.

like image 145
CrazyCoder Avatar answered Sep 22 '22 07:09

CrazyCoder