Magpie is designed to be easy to modify and adapt to new problems. This part of the manual explains how to build Magpie from source and describes how to add new features.
The the latest version of the source code for Magpie is available on BitBucket.
There are two methods for compiling a new version of Magpie: using an automated build script provided with Magpie and through an Integrated Development Environment (IDE). For both methods, you will need to install version 7 (or greater) the Java Development Kit (JDK).
The first method for building Magpie is using Apache ANT, which is kind of a Java-centric version of Make (if that helps). To use it, simply copy or link simple-build.xml
to build.xml
in the Magpie root directory. Then, call ant jar
and Ant will take care of compiling the source code, linking the libraries, and storing it all in the dist
directory.
The alternative (and recommended) method is to use an IDE to build Magpie. If you haven't already used one, IDEs are tools that provide a single platform for editing, debugging, and preparing software for distribution. Many (like Netbeans), have handy features like automatic code generation, error checking, and tools for automatically restructuring your code. There are a variety of IDEs available for writing Java programs, and you are probably better off reading their own guides for setting up a new project. Just keep in mind that you may need to tell the IDE to link with all of the libraries in the required-libraries
directory.
Now that you have a good understanding how to compile your new changes, it is time to discuss how to write new components.
Adding new functionality to Magpie will more than likely involve implementing a new version of some archetypal "Base" class. The best way to create a new implementation is to find an already existing class that is closest to what you want to do, and copy it. Make sure to place the new file in the same directory as the old implementation (very important when compiling Magpie). Once you have done that, follow this simple procedure:
Creating new text commands for the Magpie interface is certainly a more advanced topic. The general idea for adding a new command is to alter the runCommand(List<Object>) operation for the class in question. The source code for BaseModel and its implementations should give you a detailed set of examples for how to write new commands and how to document them. Read the JavaDoc for Commandable for more details on both.
A few pitfalls to watch out for: