This is an old revision of the document!
Table of Contents
This tutorial aims at showing how to get started on GroIMP plugin development. It is assumed that you are able to compile the plugin using Maven (either the plugin alone, or the whole project). In this tutorial we are going to create a new plugin (from the empty template), add a new MimeType (format of file accepted by GroIMP) for both import and export, and add a menu item that run a specific command.
See:
Initialize the plugin
Download a template
First download the default empty template from the repository.
Once downloaded, you should have a directory called newplugin-maven, which contains a src
folder, a pom.xml
file, and some additional files for deployment (which we will not modify here).
You can, and should, rename the directory with the name you want for your plugin. For the rest of this tutorial, the directory is called newplugin
.
We can start editing it using a text editor/ or IDE (e.g. Eclipse) of your choice.
Change the main data
A plugin requires to: have a maven (pom) file working, and a groimp (plugin.xml) file working.
Pom file
Let's start with the maven file:
- It needs a parent version in the following replace the x.x by the version of GroIMP you want to use. Here we can use 2.1.5,
<parent> <artifactId>GroIMP</artifactId> <groupId>de.grogra</groupId> <version>x.x</version> </parent>
- The plugin needs a java name, this is the java identifier of the plugin. Here we can use template.plugin.tutorial.
<artifactId>template.plugin.tutorial</artifactId>
- Any additional dependencies to other java package (including GroIMP package) need to be declared,
</dependency> <dependency> <groupId>de.grogra</groupId> <artifactId>graph</artifactId> <version>x.x</version> </dependency> ... </dependencies>
Plugin xml
Now, we need to change the GroIMP files, go in the directory src/main/resources
and open plugin.xml:
- The plugin id should match the java id:#
<plugin id="de.grogra.template.plugin.tutorial" ...
- The file name must match the directory name:
<library file="newplugin" prefixes="{de.grogra.template.plugin.tutorial}"/>
- All imports must also be declared here:
<import plugin="de.grogra.graph"/>
...
Plugin properties
Now edit the plugin.properties
file to update the plugin name, it needs to match the directory name:
pluginName = newplugin