wiki:PluginDevelopmentGuide

Version 3 (modified by jri, 7 years ago) (diff)

Setup for Hot-Deployment

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: Tagging

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.

Create the plugin

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

Setup for Hot-Deployment

In order to let DeepaMehta hot-deploy the plugin you must include it in DeepaMehta's hot-deployment list.

Add the line /home/myhome/deepamehta-dev/dm4-tagging to DeepaMehta's pom.xml. Impotant: append a comma to the previous line:

<project>
    ...
    <felix.fileinstall.dir>
        <![CDATA[
            ${project.basedir}/modules/dm4-core/target,
            ...
            ${project.basedir}/modules/dm4-storage-neo4j/target,
            /home/myhome/deepamehta-dev/dm4-tagging
        ]]>
    </felix.fileinstall.dir>
</project>

Now start DeepaMehta:

cd deepamehta
mvn pax:run

This starts DeepaMehta in development mode, that is with hot-deployment activated. The terminal gets occupied by the Gogo shell now. Type lb to see the list of deployed bundles. Your plugin does not yet appear in that list as it is not yet build.

Build the plugin

In another terminal:

cd dm4-tagging
mvn clean package

This builds the plugin and hot-deploys it.

Attachments