Plugin Development
Creating a custom Anteater plugin allows you to extend the functionality of Anteater to accommodate specialized tasks, workflows, or integrations. This guide explains the steps needed to create an Anteater plugin and the required dependencies you’ll need during the development process.
Getting Started
To create an Anteater plugin, begin by deciding which core Anteater dependency aligns with your needs:
<dependency>
<groupId>com.ganteater</groupId>
<artifactId>anteater-cli</artifactId>
<version>1.2.1</version>
</dependency>
If your plugin needs a graphical Editor panel component for use in the desktop application of Anteater, include:
<dependency>
<groupId>com.ganteater</groupId>
<artifactId>anteater-desktop</artifactId>
<version>1.2.1</version>
</dependency>
Streamline Development with a Parent Project
To simplify plugin creation, you can use the com.ganteater.plugins:ae-plugins as a parent project. This is not strictly required, but it helps set up essential configurations, such as dependencies and build structures, seamlessly.
Here’s how you can include it as a parent project in your plugin’s pom.xml:
<parent>
<groupId>com.ganteater.plugins</groupId>
<artifactId>ae-plugins</artifactId>
<version>1.2.1</version>
</parent>
If you choose not to use the parent project, make sure to include the required dependencies and plugins manually in your build file.
Steps to Create an Anteater Plugin
Follow these steps to create your Anteater plugin:
1. Setup Your Development Environment
- Start by creating a new Maven project or by using your preferred build tool (Maven is recommended).
- Choose either anteater-cli or anteater-desktop as your primary dependency based on your requirements.
- Optionally, include the ae-plugins parent project in your pom.xml.
Example Maven Project Structure:
ae-myplugin/
├── pom.xml
├── src/
├── main/
│ ├── java/ # Your plugin source code
│ │ └── com/ganteater/ae/processor/...
│ ├── resources/ # Plugin resources (e.g., configurations, assets)
│ └── ...
└── manual-test/
└── ae.xml
├── recipes
│ └── ...
└── ae.xml
com.ganteater.ae.processor
is a default package for anteater plugins. For this package you can use only class name in you recipe:
<Extern class="MyCustomProcessor">
...
</Extern>
Otherwise, the fully qualified class name should be used.
2. Add Required Dependencies
Include any additional dependencies your plugin will need. For example:
- Database drivers (e.g., PostgreSQL, MySQL).
- API SDKs (e.g., AWS SDK, Twilio).
- XML processors, web libraries (e.g., Jsoup for HTML interactions).
For example:
<dependencies>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.3</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.27</version>
</dependency>
</dependencies>
3. Define Your Custom Processor
The core of your plugin is its Processor. This is where you implement the logic your plugin will execute.
Extend Anteater’s base processor class (e.g., BaseProcessor) or any relevant processor interface. Implement the required methods (e.g., runCommandMyCommand(Node action)).
Example:
public class MyCustomProcessor extends BaseProcessor {
@Override
public void init() throws CommandException {
...
}
@CommandExamples({ "<MyCommand name='type:property' />" })
public void runCommandMyCommand(Node action) {
...
}
4. Optional: Add a Desktop Editor Panel
If you’re creating a desktop plugin and want to include a Graphical Editor panel component, you can build custom UI elements using anteater-desktop. These components allow users to interact with your plugin visually. Example: Creating an Editor Panel
package com.ganteater.ae.desktop.editor;
import com.ganteater.core.ui.EditorPanel;
import javax.swing.JPanel;
public class MyEditorPanel extends JPanel implements Editor {
@Override
public void init(TaskEditor taskEditor, Node node) throws CommandException {
...
}
...
}
5. Test
For run and test you plugin you can use ae-maven-plugin:
$ mvn ae:run
6. Package and Deploy
Compile your project into a .jar file and place it in Anteater’s plugins directory. Packaging Commands:
Using Maven:
$ mvn clean install
If you need to create single jar file:
$ mvn clean install assembly:single
The resulting .jar file will be located in the target/ directory of your project. Add it to the plugins folder of your Anteater installation, and you’re good to go! Don’t forget to verify the configuration in ae.xml. Best Practices for Plugin Development
-
Design for Reusability: Write clear, modular code so your plugin can be reused in multiple projects or workflows.
-
Adhere to Anteater Standards: Ensure your plugin integrates seamlessly with Anteater's core structure and recipes.
-
Use Libraries Wisely: Avoid adding unnecessary dependencies to minimize the size of your plugin and reduce compatibility issues.
-
Write Clean, Readable Code: Follow coding standards (like proper naming conventions and documentation) so others can understand and collaborate on your plugin.
-
Document Your Plugin: Include clear instructions on how to configure, install, and use your plugin in Anteater workflows.