Eclipse Monkey

Eclipse Monkey is a dynamic scripting tool for the automation of routine programming tasks. Monkey scripts are little Javascript programs using either the Eclipse APIs or custom Monkey DOMs.


If you're reading this, Eclipse Monkey is already installed.

(If you're reading this outside the Eclipse help system, then Eclipse Monkey might not be installed, in in which case all you need to know is that Eclipse Monkey is an Eclipse feature (a set of plug-ins) that you can install with the Update Manager.)

Eclipse Monkey comes with a few example scripts. To install the examples, use the Create the examples project toolbar button.

Running a script

Scripts are run by selecting a script from the Monkey menu. Future versions will offer additional ways to run scripts, such as triggering on changes to a files or other resources, or on specific events (e.g., on team synchronize, or on publish war to app server, etc).

Writing a script

Scripts are installed in the Monkey menu by placing them in "*.em" files in a top-level "monkey" folder of any project (obviously, scripts are un-installed by renaming or moving them).

Scripts include metadata that specifiy how a script is to be run and (in a future release) additional resources required for successful operation. Metadata consists of keyword values pairs. These are placed in the first comment block of the script. This must be a /* ... */ style comment.

The Menu: metadata tag specifies that this script is to be included in the Monkey menu. If more than one script specifies the same menu item, the menu item will appear more than once.

Scripts manipulate script objects such as strings and arrays, native Java objects including native Eclipse objects, and special DOM objects made specifically to simplify scripting.

Native Java objects can be accessed through their fully qualified class names. Eclipse objects require that the fully qualified name be prepended with the additional name "Packages". Here are some valid scripting expressions that show how this works

DOM objects appear as globals in the script namespace. Some DOMs are primitively supported, others are supplied by Eclipse Monkey DOM plug-ins. The DOMs available with this release are:

Learn about these DOM through the examples or by reading the source code of the Eclipse Monkey Standard DOMs plug-in.

Publishing a script

Eclipse Monkey scripts are short and easily published to blogs, wikis, bugzillas, and all sorts of other places. To publish one (or more) scripts, select the files in the Navigator and use the Copy for Publication... context pop-up menu. Eclipse Monkey provides different publication formats for different destinations, e.g., blogs typically use HTML, wikis use indented text, bugzilla uses straight text, etc. The pop-up menu places the scripts on the clipboard for you to paste into your blog/wiki/bugzilla/whatever.

Eclipse Monkey decorates each script with Jabberwocky-inspired header and footer - you should leave these on as they are necessary for the script retrieval system (described below).

Retrieving a script

When you see a script that you like - in a blog, on a web page, in an email, or whereever - Eclipse Monkey has a quick and easy retrieval mechanism.

  1. Select all the text on the web page (on a Macintosh use Cmd-A; on a Windows box use Ctrl-A)
  2. Copy the text (Cmd-C or Ctrl-C)
  3. Switch to Eclipse (Cmd-Tab or Alt-Tab)
  4. Use the Monkey / Paste New Script menu item
The Paste New Script menu finds the Jabberwocky-inspired headers and footers, extracts the scripts between them, and places them into new script *.em files. These new script files are placed in the "Eclipse Monkey Scripts" project (which is, of course, created if it doesn't exist yet). After you test the new script, you can move it to your own project or leave it in the "Eclipse Monkey Scripts" project or publish it in your own blog or ...