Eclipse Maven Build and Test with One Button

前端 未结 3 782
甜味超标
甜味超标 2020-12-17 23:13

The most common build activity I do in Eclipse (other than allowing auto-build to do its thing) is to perform a \"Maven Build...\" with parameters of clean and package. Thi

相关标签:
3条回答
  • 2020-12-17 23:18

    It looks like there's a couple of ways to do this - none directly in Eclipse:

    • Create your own small plugin that defines the key binding, see here: eclipse: put keyboard shortcuts on specific launch configurations
    • Use Practically Macro - also see here: Assigning a keyboard shortcut for a specific Eclipse build configuration
    • Use some form of scripting, e.g. this: http://mackaz.de/72
    0 讨论(0)
  • 2020-12-17 23:21

    I've rediscovered key bindings in Eclipse. It's not exactly what I want, but it works well enough, I suppose. I simply bind F7 to Maven's test hook. It's not the same as "mvn clean package" but it'll do until I find a better solution.

    Here's how I did it:

    1. Open preferences
    2. Open General->Keys
    3. Search for "maven test" (or "run maven test")
    4. Select the Run Maven Test entry
    5. Click on the field labeled Binding
    6. Press F7 (or whatever keystroke you want to bind)
    7. Probably best to set the When field to in Windows

    Now, when you press F7, eclipse will run "mvn test".

    For whatever reason, and I'm sure it's a perfectly good one, the m2eclipse plugin authors didn't provide a "Run Maven package" hook. Sigh.

    0 讨论(0)
  • 2020-12-17 23:25

    If you create a Maven Run Configuration and put a number as the first character in the name, then you can use Shift-Alt-X Ctrl-M N, where N is the number you gave as first character in the name. For your case, do the following.

    1. Right click on your project, select Run As and then select Maven build... This will open a dialog to create a new Maven Run Configuration.
    2. Make the name of the configuration 1 - test.
    3. Put test as the goal.
    4. Press Apply and then Close.
    5. Type Shift-Alt-X Ctrl-M 1. This will select the configuration you just created.
    6. Press enter will launch it.
    0 讨论(0)
提交回复
热议问题