简体   繁体   English

IntelliJ IDEA:在运行/调试配置之前和之后运行批处理脚本

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

Background: 背景:

I have a Run config that runs a maven build. 我有一个运行maven构建的运行配置。 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. 我已经设置了一个Context Path来查看Build目录的Target Directory,因此我不必每次运行构建时都手动复制war文件。

What I would like is for my build config to automatically kill the running tomcat process, run the build, and (if successfull) restart tomcat. 我想要的是我的构建配置自动杀死正在运行的tomcat进程,运行构建,并且(如果成功)重启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: 我想在构建之前和之后简单地调用启动/停止tomcat批处理文件,但我遇到了两个障碍:

  • In the Build Config->Before Launch section, there's no option to execute a batch script 在Build Config-> Launch Before部分中,没有执行批处理脚本的选项
  • There doesn't seem to be an "After build" section to complete Phase 2 似乎没有“After build”部分来完成第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? 是否可以按顺序(一个接一个)运行构建配置,是否有插件或其他东西来创建批处理脚本构建配置?

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. 无法直接在IDEA中运行批处理脚本,并且在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). 在IDEA 12中,可以指定在运行之前要执行的多个操作,这样您就可以创建将重启Tomcat的Maven目标(通过运行批处理脚本或其他方式),并在Before Launch列表中指定2个操作:kill运行Tomcat进程(可以是另一个Maven目标,另一个运行配置或Ant任务)并运行构建(Maven目标)。 Here is how this UI looks like in IDEA 12: 以下是此ID在IDEA 12中的外观:

发布之前

When you run this configuration, it will kill Tomcat, perform the build and restart Tomcat. 运行此配置时,它将终止Tomcat,执行构建并重新启动Tomcat。

It should also work if you chain multiple Run configurations with the Run Another Configuration Before Launch step. 如果使用“ Run Another ConfigurationRun Another Configuration步骤链接多个“运行”配置,它也应该有效。

IDEA 12 is planned for the end of 2012, but first EAP versions will be available in several weeks. IDEA 12计划于2012年底推出,但首批EAP版本将在几周内上市。


Another solution would be to use a single Maven goal with Mojo Executor or Ant task that will perform all the 3 actions. 另一个解决方案是使用Mojo Executor或Ant任务执行所有3个操作的单个Maven目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM