05_developer_tutorials:02_extending_groimp:creating-own-plugin
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| 05_developer_tutorials:02_extending_groimp:creating-own-plugin [2025/01/31 15:33] – removed - external edit (Unknown date) 127.0.0.1 | 05_developer_tutorials:02_extending_groimp:creating-own-plugin [2025/01/31 15:33] (current) – ↷ Page moved from 04_developer_documentation:dev-guide:creating-own-plugin to 05_developer_tutorials:02_extending_groimp:creating-own-plugin tim2 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== Creating a new Plugin ===== | ||
| + | |||
| + | ==== Plugin structure ==== | ||
| + | |||
| + | The GroIMP software can be extended by plugins. This page describes how to write a plugin named MyPlugin. | ||
| + | |||
| + | Firstly, a plugin has to have a special directory layout. The layout depends on how you run GroIMP. There are currently two layout: | ||
| + | - As compiled plugin. | ||
| + | - As compiled classes. | ||
| + | |||
| + | In the compiled version of GroIMP (the one deployed and installed with the executable files) the plugins are loaded as: | ||
| + | |||
| + | * MyPlugin | ||
| + | * MyPlugin.jar | ||
| + | * plugin.properties | ||
| + | * plugin.xml | ||
| + | * doc/ | ||
| + | * dependencies.jar ... | ||
| + | |||
| + | In the development version of GroIMP (usually what you get from the source code, and using the --project-tree argument) the plugins are loaded as: | ||
| + | |||
| + | * MyPlugin | ||
| + | * target | ||
| + | * classes | ||
| + | * plugin.properties | ||
| + | * plugin.xml | ||
| + | * < | ||
| + | * < | ||
| + | * lib | ||
| + | * <needed jar-files> | ||
| + | |||
| + | **Important: | ||
| + | |||
| + | By default GroIMP load plugins from its root/ | ||
| + | |||
| + | ==== Using Maven ==== | ||
| + | |||
| + | The compiled plugins follow the maven project structure. You can get a template plugin [[https:// | ||
| + | |||
| + | * MyPlugin | ||
| + | * pom.xml | ||
| + | * src | ||
| + | * main | ||
| + | * java | ||
| + | * <Java source files> | ||
| + | * resources | ||
| + | * plugin.properties | ||
| + | * plugin.xml | ||
| + | * doc/ | ||
| + | * < | ||
| + | * assembly | ||
| + | * < | ||
| + | * lib | ||
| + | * <needed jar-files> | ||
| + | |||
| + | The default template includes the assembly files, which you do not have to change for the packaging to a GroIMP plugin. | ||
| + | |||
| + | If possible the third party dependencies should be defined in the pom.xml file and not added to the lib directory. During the maven compilation, | ||
| + | |||
| + | === Maven property file (pom.xml) === | ||
| + | |||
| + | Afterwards, you should update the pom.xml file which is used by the Maven tool. Even if you use an IDE for development, | ||
| + | |||
| + | <code xml> | ||
| + | <?xml version=" | ||
| + | <project xmlns=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | |||
| + | < | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | The first part - plugin info: | ||
| + | |||
| + | <code xml> | ||
| + | <?xml version=" | ||
| + | <project xmlns=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | |||
| + | < | ||
| + | </ | ||
| + | |||
| + | defines: | ||
| + | - The link dependencies to a GroIMP version (under < | ||
| + | - An artifactId for your plugin, which should start with a lowercase letter. This is the unique identifier of your plugin. | ||
| + | - The name of your plugin (in the < | ||
| + | |||
| + | The second part - remote properties: | ||
| + | |||
| + | <code xml> | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | defines: | ||
| + | - The repositories where the plugin should look for custom dependencies. The first // | ||
| + | - The additional properties, here // | ||
| + | |||
| + | The third part - dependencies: | ||
| + | |||
| + | <code xml> | ||
| + | < | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | </ | ||
| + | </ | ||
| + | |||
| + | defines the dependencies to: | ||
| + | - the other GroIMP plugins. The groupId is always de.grogra for GroIMP plugins. | ||
| + | - the third party libraries. As yourlib.jar is accessible from Maven Central (i.e. deployed online), it is best to load it from there with the groupId and artifactId defined there.The mylib.jar being a local dependencies, | ||
| + | |||
| + | Finally, the build section: | ||
| + | |||
| + | <code xml> | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | it defines that the plugin will be packaged with its < | ||
| + | |||
| + | |||
| + | Now that the Maven file is ready, you can compile, package or install you plugin with the commands: //mvn compile//, //mvn pakcage//, //mvn install// | ||
| + | |||
| + | |||
| + | ==== Plugin configuration (For Groimp integration) ==== | ||
| + | |||
| + | === Plugin properties === | ||
| + | |||
| + | The file _plugin.properties_ must exist in the plugin path. It can be empty, but should contain the plugin name and provider. It can also include some information on the plugin license and link. Here is an example: | ||
| + | |||
| + | < | ||
| + | pluginName = The name of your plugin | ||
| + | provider = grogra.de | ||
| + | |||
| + | aboutplugin.License = GPL | ||
| + | |||
| + | aboutplugin.tabs = license | ||
| + | aboutplugin.tab.license = License | ||
| + | aboutplugin.tab.license.content = gpl.html | ||
| + | </ | ||
| + | |||
| + | The // | ||
| + | |||
| + | You can also define other resources to be accessible from GroIMP in the _plugin.properties_, | ||
| + | [[01_user_documentation: | ||
| + | |||
| + | === Description === | ||
| + | |||
| + | Then you have to create the plugin.xml file which is read by GroIMP to obtain required information about the plugin. | ||
| + | |||
| + | <code xml> | ||
| + | <?xml version = " | ||
| + | <plugin | ||
| + | id=" | ||
| + | version=" | ||
| + | xmlns=" | ||
| + | |||
| + | <import plugin=" | ||
| + | <import plugin=" | ||
| + | |||
| + | <library file=" | ||
| + | <library file=" | ||
| + | <library file=" | ||
| + | |||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | The id of MyPlugin can be chosen freely, and it must match with the name defined in the maven file < | ||
| + | |||
| + | === Groimp menu entries === | ||
| + | |||
| + | Within the registry-element, | ||
| + | |||
| + | |||
| + | ===== Embedded documentation ===== | ||
| + | |||
| + | The embedded documentation of GroIMP is based on the docbook format with the htmlhelp template. | ||
| + | The docbook file must be created in src/ | ||
| + | There are several docbook editors available online. | ||
| + | With GroIMP 2.1.4 it is also possible to use a markdown file as a source of documentation, | ||
| + | A documentation on the Markdown based approach can be found [[05_developer_tutorials: | ||
| + | |||
| + | The compilation including the embedded help is described [[05_developer_tutorials: | ||
| + | |||
| + | The linking of the embedded documentation | ||
| + | |||
| + | ===== Linking an example ===== | ||
| + | |||
| + | In order to make your plugin easier to get started with, it is recommended to add an example project with it. The example projects are available in GroIMP from the [[01_user_documentation: | ||
| + | |||
| + | To include an example project,the gsz file needs to be placed in ' | ||
| + | |||
| + | <code xml> | ||
| + | <ref name=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | </ | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | Where: | ||
| + | * ref name=" | ||
| + | * CATEGORYNAME is the category where the example will be grouped. | ||
| + | * PROJECTNAME is a name, that is used by default when displayed. But it can be overwritten in the properties. | ||
| + | * PROJECTVERSION is the version. One project can have several versions. They will all be available in the project explorer, by selecting them in the drop-down menu. Versions of one project need to be added within the same tag '' | ||
| + | * FACTORYNAME is the default name displayed. Can be overwritten in the properties. | ||
| + | * PROJECTFILE.gsz (and any OTHERFILE.gsz) the relative path to access the project file. Usually, both the '' | ||
| + | |||
| + | |||
| + | The displayed name can be changed in the '' | ||
| + | |||
| + | < | ||
| + | / | ||
| + | |||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ===== Linking a Template ===== | ||
| + | |||
| + | Similar to the examples a FilterSourceFactory can be used to add new templates. Templates are the files that can be selected by creating a new project ' | ||
| + | To add a gsz file stored in ' | ||
| + | |||
| + | <code xml> | ||
| + | <ref name=" | ||
| + | <ref name=" | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | Additionally the name shown in the menu can be set in the properties file. | ||
| + | |||
| + | See more: | ||
| + | |||
| + | [[01_user_documentation: | ||
| + | |||
