Set Up a new Plugin
When creating a default plugin for your metamodel, there is very little you have to do yourself. This page discusses the flow to set up a default plugin. Any customization wishes will be discussed afterwards.
Step 1: The plugin initializer
From version 6.1.0, the ns-initializer includes the plugin-initializer by default. There are two ways to use this
plugin-initializer:
- CLI:
- Create a directory for your plugin called
{plugin-name}-plugin. - Run the command
nsinit plugin
- Create a directory for your plugin called
- µRadiant:
- Go to
Settings-->Initializer. Make sure there is a Project Init Optionnsinit plugin. - Go to the
Open...tab and clickInitialize Project.... Choose plugin and insert a name.
- Go to
The initializer will setup a plugin project with:
- An expansionSettings file with the needed resources.
- Your program
EditorPlugindefined. - The necessary scripts
Step 2: Linking your metamodel
After plugin initialization, you need to define the target metamodel for this plugin. Due to the current design of
the ns-model-server, this can only be done in the plugin.xml itself, and not via the µRadiant UI.
- Add an
EditorMetamodelof typesourceto target the ontologies you want to build a plugin for. - The
elementsis added as dependency ontology by default. However, if you need other ontologies as dependency, they can be added in the same way. An example:
<metamodels>
<editorMetamodel>
<ontologies>
<ontology>"YOUR SOURCE ONTOLOGY HERE"</ontology>
</ontologies>
<type>source</type>
</editorMetamodel>
<editorMetamodel>
<ontologies>
<ontology>elements</ontology>
</ontologies>
<type>dependency</type>
</editorMetamodel>
</metamodels>
- When adding ontologies in the
plugin.xml, you need their resource as well. Add this to your expansionSettings.
Now your target metamodel is configured in the plugin.
Step 3: Generate Skeleton
In the /scripts folder, you will find a generate-skeleton.nss script. This script runs the
GeneratePluginSkeleton transmuter.
The transmuter:
- creates a basic model skeleton for the plugin. It creates an
EditorModelExtensionwith all the model basics. - can be rerun when the metamodel is updated.
- generates generator logs that keep track of changes that were already applied. This means, if you add changes in
the
EditorModelExtensionyourself, these will still be there after rerunning the transmuter. - does currently not delete anything in the
EditorModelExtensionwhen things are deleted in the metamodel.
The EditorModelExtension generated by this script, is a complete setup for a default working plugin. You can check the generated model by opening the plugin in the µRadiant.
Since the plugin is an expandable project, you should now expand the project to generate the angular app.
Step 4: Testing the Plugin
It is possible to locally test your plugin. After expansion, you would need to perform the following steps:
- verify if a
yarn.lockfile exists in/expansions/{pluginName}-plugin. If it does not, create an emptyyarn.lockfile in that directory. - The µRadiant plugins get their model information from an ns-model-server. You need an example project from the target metamodel. (This could have been generated by the metamodel-initializer)
- To start this model server run the
start-model-serverscript with the following argument:
nss ./scripts/start-model-server.nss "/path/to/example/project/conf/expansionSettings.xml"
- Run the Angular app:
- Before the first run or after an update, you will need to install dependencies:
yarn - Then run the applicationApplicationThe overarching model container grouping all components, domain logic, and configurations for an enterprise solution.:
yarn start
- Before the first run or after an update, you will need to install dependencies: