8

Now that I am using gradle for all of my new development, I'm running into issues with BuildShip features I really don't want.

For instance, when I hit the Run hotkey when I have a unit test open in Eclipse, I only want it to run as a JUnit test, alone. But Gradle has inserted its own hooks and option, which means extra clicking or keypresses beyond the one-stroke hotkey I have assigned to Run that I can tell it I want JUnit. (The gradle test option actually runs all tests, which takes minutes.).

Question: Is there a way to remove this hook in gradle without diving into the source code and ripping out functionality myself?

This isn't the only interference (interfering with run last is another), but it's my #1 annoyance about BuildShip.

"run as"

Essentially, I want this popup to stop happening.

A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
Alice Young
  • 1,742
  • 2
  • 11
  • 19

2 Answers2

2

Indeed you cannot change the available launchers prompt but you can change the default hotkeys related to each launcher and directly use the one you prefer.

From Windows > Preferences > General > Editor > Keys you can get the list of available hot-key mappings. Filter the (long) list by typing test as show below:

enter image description here

As you can see you have several mappings for running JUnit tests: Gradle, JUnit runner, Maven.

The default configuration for JUnit runner is Alt+Shift+X,T, not really user friendly I would say.

I changed it to a more concise Alt+U down in the Binding option and applied the changes. Now you can run any JUnit test on its open editor windows without any prompt, simply type Alt+U and the JUnit runner will be triggered automatically for that single unit test.

A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
0

This is a major usability annoyance in Eclipse+Buildship. I perform the following steps every time Buildship upgrades to get rid of that annoying popup, and also avoid the (for me, useless) Gradle test process when what I really want is for the last test to run while I am not in that particular class. Admittedly, this is invasive, but it works while keeping the "good" parts of Buildship.

Open up the plugins folder and look for the org.eclipse.buildship.ui_*.jar. (I do this on a Mac, which requires showing the contents of the Eclipse.app first.) Open the .jar file in some zip file editor which can modify files within the zip file (I use BetterZip on Mac, I think Winzip and 7Zip probably work too.) Edit the plugin.xml file.

This is for the new Photon 4.8 release of Eclipse. Remove (or comment out) the following two sections:

  • The <command> element with id="org.eclipse.buildship.ui.shortcut.test.run"
  • The <extension> element with the comment <!-- "Gradle Test" entry in the "Run as... " context menu --> above it (about 30 lines)

Save the file, which should be noticed by BetterZip/Winzip and let it update the .jar file with the changed content. Finally, eclipse needs to be restarted with the -clean switch so that it does not use a cached copy of the jar file. For example, on Mac:

cd /Applications/eclipse-jee-photon-R-macosx-cocoa-x86_64/Eclipse.app/Contents/MacOS /.eclipse -clean

Buildship will now no longer bother you with that popup or run the Gradle test within Eclipse, because the UI entry points have been removed. Unfortunately, on the next update of Buildship you need to repeat the process again on the new jar.

John Churchill
  • 342
  • 4
  • 11