wiki:PluginDevelopmentGuide

Version 2 (modified by jri, 12 years ago) (diff)

A very simple plugin

Plugin Development Guide

DeepaMehta is made to be extensible by 3rd-party developers. Developers extend DeepaMehta by developing plugins (resp. "modules" resp. "applications" which is all synonymous).

Setup the development environment

The best way to start with DeepaMehta plugin development is to build DeepaMehta from source. This way you get a hot-deploy environment, that is DeepaMehta redeploys your plugin automatically once you compile it. This is very handy while development.

Requirements:

  • Java 6 (newer versions might work as well, older versions do not work)
  • Maven 3 (older versions do not work)
  • Git

Build DeepaMehta from source:

git clone git://github.com/jri/deepamehta.git
cd deepamehta
mvn install -P all

A very simple plugin

Let's start with a very simple plugin. This plugin will just create a new topic type called Tag. Once the plugin is installed the topic type will appear in the DeepaMehta webclient's Create menu, so you can create instances. And you will be able to fulltext search for tags.

Developing such a simple plugin involves no Java coding at all. All is declarative, mainly in JSON format.

Of course the topic type could be created interactively as well, by using DeepaMehta's type editor. However, being packaged as a plugin you can publish it. When other DeepaMehta users install your plugin they can use your type definitions.

You create the plugin just by creating directories and text files. A DeepaMehta plugin project adheres to a certain directory structure and file name conventions.

Setup a directory structure as follows:

dm4-tagging/
    pom.xml
    src/
        main/
            resources/
                migrations/
                    migration1.json
                plugin.properties

Create the file pom.xml with this content:

<project>
    <modelVersion>4.0.0</modelVersion>

    <name>DM4 Tagging</name>
    <groupId>org.mydomain.dm4-plugins</groupId>
    <artifactId>tagging</artifactId>
    <version>0.1-SNAPSHOT</version>
    <packaging>bundle</packaging>

    <parent>
        <groupId>de.deepamehta</groupId>
        <artifactId>deepamehta-plugin-parent</artifactId>
        <version>4.1.1-SNAPSHOT</version>
    </parent>
</project>

Create the file migration1.json:

{
    topic_types: [
        {
            value: "Tag",
            uri: "domain.tagging.tag",
            data_type_uri: "dm4.core.text",
            index_mode_uris: ["dm4.core.fulltext"],
            view_config_topics: [
                {
                    type_uri: "dm4.webclient.view_config",
                    composite: {
                        dm4.webclient.show_in_create_menu: true
                    }
                }
            ]
        }
    ]
}

Create the file plugin.properties:

requiredPluginMigrationNr = 1
importModels = de.deepamehta.webclient

Attachments