Make Maven Project visible to Eclipse WTP

If you are like me and taking advantage of Eclipse WTP to keep everything close together and deploy your web applications inside of Eclipse IDE then chances are that you might already have considered doing the same for a project with a Maven flavor.

Sonatype’s M2Eclipse plugin provides very nice interoperability for Maven related actions inside of the Eclipse platform, from creation or materialization of Maven projects to source/documentation downloading options, special visualization of the POM file or even repository and indexing functionalities.

Therefore having in the POM:

<packaging>war</packaging>

is enough for Maven’s magic:

mvn package

to create the war file. All good up until now.

Say for instance we now want to deploy this into Tomcat from inside Eclipse WTP tooling platform. In case the web module is NOT showing under the “Add and Remove” section of servers/new servers in Eclipse here’s what you need to do if you don’t want to spend hours of frustration:

  • This is most likely happening because you are missing the Maven integration with WTP, something that can be installed as a plugin from the M2Eclipse Extras Eclipse compatible url update site.
  • If even after the above the module is still not visible, it’s because the Eclipse Maven project you are working on was initially created as a non-Maven project and you’ve added the Enable Dependency Management option from the M2Eclipse plugin. In that case, create a New Maven Project or Import an Existing Maven Project and that should hopefully do the trick.

Useful Eclipse Shortcuts Mac OS X

  • Cmd + Shift + O: Removes all unused imports.
  • Cmd + Shift + F: Code beautifier.
  • Cmd + Alt + DOWN: Duplicates the current line.
  • Ctrl + Shift + UP: Wherever the cursor, while keep hitting UP, the next current bigger entity is getting selected i.e. current word > current phrase > current statement > current line > current method body > current method > current class > current file.
  • Ctrl + H: Search tab.
  • Ctrl + 1: Applying all suggested fixes.
  • Cmd + T: Type hierarchy for the current cursor item. Repeat the shortcut a second time to see superclasses hierarchy.
  • Cmd + Shift + R: Resources tab that dynamically retrieves resources, mostly you’ll need it for classes, interfaces, enums and config files to bring up.
  • Cmd + Shift + T: Same as its cousine Cmd + Shift + R, but dynamically autocompletes only types (classes, interfaces) in the search tab.
  • Cmd + D: Delete current line.
  • Cmd + M: Minimize/Maximize current tab.
  • Cmd + N: New tab in the selected item in the Package Explorer.
  • Cmd + O: Quick Outline. Similar to the Outline view.
  • F3: Drilling into current cursor location.
  • Cmd + Left Mouse Click: Open Implementation option appears that polymorphically gives you all options. I.e. whenever F3 gets to to an interface method, Cmd+Left Click presents you with all the override options instead which is 99% of the cases where you want to navigate.
  • Ctrl + Alt + H: Call Hierarchy. Summarises all places where this method has been called.