Skip to main content

Plugin Development

Plugin Initializer

There is an initializer for plugin projects.

https://github.com/normalizedsystems/nsx-mr-plugin-initializer

You will need to configure the ns-initializer, adding the plugin-initializer. The process is described here.

Setup

Plugins projects are expanded.

The expansionSettings file uses mr-plugin-expanders expansion-resource to expand. It uses the editorElements::EditorPlugin programType. The target will always be plugin

The plugin models use profiles to configure features. There are 2 profiles to choose from:

  • Standard Plugin 3 (basic setup using yarn)
  • NSX Plugin 3 (adds nsx-parent and other nsx related configuration)

The plugin model is found under the model/ directory.

change management

Changes in the mr-plugin-expanders are introduced by defining new profiles. That way, functionality is kept the same for existing plugins on update. The plugin projects can move to a new profile to make use of the new features.

Plugin Model

Plugin XSD

There are XSDs, which can help you to correctly edit the plugin XML files. They are included in the editor-core jar. You can access them by adding the following dependency to your pom.xml.

    <dependency>
<groupId>net.democritus.editor</groupId>
<artifactId>editor-core</artifactId>
<version>${editor-core.version}</version>
</dependency>
model/plugin.xml contains some general information
<editorPlugin xmlns="https://schemas.normalizedsystems.org/xsd/editorElements/3/0/0">
<!-- Name is used to identify the plugin. Also used in artifact id. -->
<name>build</name>
<version>0.1.2-SNAPSHOT</version>
<!-- Plugin id is used to register the plugin in the prime radiant.
Should not be changed after release. -->
<pluginId>net-democritus-build-plugin</pluginId>
<!-- Group id for maven artifacts. -->
<groupId>net.democritus.editor</groupId>
<description>Provides build page</description>
<pluginDependencies>
<!-- Add references to other plugin artifacts to include them during local development. -->
<pluginDependency>
<pluginName>prime</pluginName>
<artifact>net.democritus.editor:mrp-prime-plugin:1.3.1</artifact>
</pluginDependency>
</pluginDependencies>
<metamodels>
<editorMetamodel>
<!-- Under dependency, add metamodel ontologies that are needed,
but which will be provided by other plugins. -->
<type>dependency</type>
<ontologies>
<ontology>elements</ontology>
<ontology>expansionControl</ontology>
</ontologies>
</editorMetamodel>
<editorMetamodel>
<!-- Under source, add metamodel ontologies that you intend to support with this plugin. (if any) -->
<type>source</type>
<ontologies>
<ontology>build</ontology>
</ontologies>
</editorMetamodel>
</metamodels>
</editorPlugin>

Generate plugin model

To initialize the plugin model, run the GeneratePluginSkeleton transmuter. This will generate extension models, which describe the Components of the plugin.

Updates

After the first time, the transmuter can be run with every update of the metamodel. The transmuter will create generator logs to keep track of what it has created, so it doesn't revert changes made by the developer. However, if the metamodel changes in a significant way, such as removing or renaming elements, you will need to fix the plugin model manually.

Local development

After expanding the plugin, you can deploy it locally and start customizing.

  • The plugin is an angular application. Run npm install and then npm start to start the plugin.
  • The plugin will need a backend to load a model. Use the scripts/start-model-server.nss script to start a model server. It takes an expansionSettings.xml location as argument. (Works best with absolute paths.)