wiki:BuildASimplePlugin

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

--

Build a simple plugin

This page describes how you can build a very simple DeepaMehta plugin. This demo plugin just creates a new topic type.

Once installed in DeepaMehta the topic type will appear in the create menu, so you can create instances. And you will be able to fulltext search for the instances.

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 your type definitions become deployable by other DeepaMehta users.

Preparation

All you need is Java 1.6 and Maven (version 3 is recommended) installed.

You don't need a DeepaMehta installation. The DeepaMehta build system will provision a DeepaMehta installation just for your plugin.

Setup the directory structure

A DeepaMehta plugin project adheres to a certain directory structure and file name conventions.

Setup a directory structure as follows:

demo-plugin-1/
    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 Demo Plugin 1</name>
    <groupId>de.deepamehta.demo-plugins</groupId>
    <artifactId>dm4-demo-plugin-1</artifactId>
    <version>4.0.RC1</version>
    <packaging>bundle</packaging>

    <parent>
        <groupId>de.deepamehta</groupId>
        <artifactId>deepamehta-plugin-parent</artifactId>
        <version>4.0.RC1</version>
    </parent>

    <repositories>
        <repository>
            <id>deepamehta-public-repository</id>
            <url>http://www.deepamehta.de/maven2</url>
        </repository>
    </repositories>
</project>

Create the file migration1.json:

{
    topic_types: [
        {
            value: "My Topic Type",
            uri: "domain.dm4_demo_plugins.my_topic_type",
            data_type_uri: "dm4.core.text",
            index_mode_uris: ["dm4.core.fulltext"],
            view_config_topics: [
                {
                    type_uri: "dm4.webclient.view_config",
                    composite: {
                        dm4.webclient.add_to_create_menu: true
                    }
                }
            ]
        }
    ]
}

Create the file plugin.properties:

requiredPluginMigrationNr = 1
importModels = de.deepamehta.webclient