Developing Plugins
This page details how to create a new plug-in in order to extend the GAML language with new skills, species, displays or operators. It also details how to create a plug-in that can be uploaded on an update site and can be installed into the GAMA release. We consider here that the developer version of GAMA has been installed (as detailled in this page).
I. Creation of a plug-in​
Here are detailed steps to create and configure a new GAMA plug-in.
-
From the Eclipse main menu tab, click on
File, thenNew, thenProject, then finally selectplug-in project.
-
In the
New plug-in Project/Plug-in projectwindow:- Choose as
namethe name of your plugin - Check
Use default location - Check
Create a Java Project - The project should be
targeted to run withEclipse working setis unchecked- Click on
Next

- Choose as
-
In the
New plug-in Project/Contentwindow:ID: could contain the name of your institution and/or your project, e.g.irit.maelia.gaml.additionsVersion:1.0.0.qualifier(this latter mention is important if you plan on distributing the plugin on GAMA update site)Name: a concise description of the plugin- Uncheck
Generate an activator, a Java class that controls the plug-in's life cycle. - Uncheck
This plug-in will make contributions to the UI - Check
Nowhen it asks if you would like tocreate a rich client application? - Click on
Next

-
In the
New plug-in Project/Templateswindow:- Uncheck
Create a plug-in using a template - Click on
Finish

- Your plug-in has been created.
- Uncheck
-
Edit the file
Manifest.MF:- From the Project Explorer pane, expand your plugin folder.
- Click on the
META-INFfolder. - Click on the
MANIFEST.MFfile.

-
Click on the
Overviewtab to open the Overview pane: -
Check as shown
This plug-in is a singleton -
Dependencies pane:
- Click on the
Dependencies.

- add (at least) the two plug-ins
gama.coreandgama.dependenciesin theRequired Plug-ins. When you click onAdd, a new window will appear without any plug-in. Just write the beginning of the plug-in name in the text field underSelect a plug-in

- Click on the
-
Click on the
Runtimetab to open the Runtime pane:
- In
Exported Packages: nothing (but when you will have implemented new packages in the plug-in you should add them there) - Add in the
Classpathall the additional libraries (.jarfiles) used in the project.
- In
-
Click on the
Extensionstab to open the Extensions pane:- Click the
Add...button and addgaml.extension
- Click the

-
On the main menu, click on
File, then selectSave, to save the file. This should create aplugin.xmlfile.

-
In the Project Explorer view, select the plugin, right click on it, and in the contextual menu select
Properties:
- The Properties dialog for your plugin opens as shown.

- In the
Propertiesdialog, go toJava Compiler, thenAnnotation Processing: checkEnable project specific settings, then inGenerated Source Directory, change.apt\_generatedtogaml,

- Go again to
Java Compiler, thenAnnotation Processing, thenFactory path: checkEnable project specific settings, thenAdd Jarsand choosegama.processor/gama.processor.jar

- Close the menu. Click on
Yesin the succeeding dialogs (Annotation settings changed ...). After, this should compile the project and create thegamldirectory.

-
Return to the
Propertiesdialog of your plugin by clicking from the main menu bar,Project, then click onProperties. Go toJava Build Path, click on theSourceTab, and check that thegamldirectory has been added.
-
If the
gamlfolder is not present, click onAdd Folder...and select thegamldirectory. Right click on the project, then refresh it (F5or from theFilemenu ->Refresh)

- Now, there should be a
gamldirectory. This gaml directory will later contain the package containingGamlAdditions.java, and other related files generated after creating classes. If there is no package in the folder, try creating a class, then try torefreshorclosethe project and reopen it, orcleanthe projects by going intoProjecttabs, and clicking onclean.
The plug-in is ready to accept any addition to the GAML language, e.g. skills, actions, operators. To proceed to creating a skill click on this link.
Do not forget to export the created packages that could be used by "clients", especially the packages containing the code of the additions (in the plugin.xml of the new project, tab Runtime).
To test the plug-in and use it into GAMA, developers have to define a new feature project containing your plugin and its dependencies, and add this feature to the existing gama.product file (or a new .product file of your own).
The use of feature project is also mandatory to define a plug-in that can be uploaded on the update site and can be installed in the release of GAMA.
Creation of a feature​
A feature is an Eclipse project dedicated to gathering one or several plug-ins to integrate them into a product or to deploy them on the update site and install them from the GAMA release (a feature is mandatory in this case).
Here are detailed steps to create and configure a new feature.
File>New>Feature project(orFile>New>Project...thenPlug-in Development>Feature Project)- In
Feature properties- Choose a project name (e.g.
institution.gama.feature.pluginsName) - Click on
Next
- Choose a project name (e.g.
- In Referenced Plug-ins and fragments
- Check
Initialize from the plug-ins list: - Choose the plug-ins that have to be gathered in the feature
- Click on
Finish
- Check
- A new project has been created. The
feature.xmlfile will configure the feature.- In
Information pane:- You can add description of the various plug-ins of the feature, define the copyright notice and the licence.
- In
Plug-ins and Fragments- additional plug-ins can be added.
- In
Addition of a feature to the product​
To load the plugin into GAMA, go into the project gama.product open the gama.product file and go into the overview tab, under the section Testing, click Synchronize, go into the Contents tab, click on Add..., and add the features related to your plugin. Click the Run tab in the main menu bar, click on Run Configurations..., then you should have the gama runtime product window open, click on the Plug-ins tab, and check the box next to your plugin in the list. Click on Apply. Now that your plugin is accessible in GAMA, we can run the application. Click on Run.
Remark: To check whether the new plug-in has been taken into account by GAMA, after GAMA launch, it should appear in the Eclipse console in a line beginning by >> GAMA bundle loaded in .
If you plan to deploy your plugin to be used by other users from the GAMA community, proceed with the succeeding steps. If not, we can proceed with the creation of skills and types.
In the product, e.g. gama.product in the gama.product project:
- go to
Contentspane- Click on
Add...button - In the window select the feature
- Click on
OK.
- Click on
Create examples model​
In order to make your plugin usable by everyone, it is very important to bring potential users model examples to introduce new gaml primitives, statements and operators. This way, modelers can easily get into the plugin you developed in a practical way.
The process is twofold:
- Mount your plugin into your GAMA (see below or use the
gitversion) - Create a new project in the user model folder. Put your GAMA model examples there.
- Move your project into a folder called
modelsat the root of the plugin
Once this is done, you can refresh your Plugin models library folder and have access to the plugin models
How to make a plug-in available at GAMA update site for the GAMA release​
Considering a working GAMA plugin named institution.gama.pluginsName
Configure plugin to be available for Maven​
Add pom.xml for plugin institution.gama.pluginsName:​
- Right click on the project->
Configure->Convert to maven project. - In the dialog that opened, set the values as this:
Group id:institution.gama.pluginsNameArtifact id:institution.gama.pluginsNameVersion:1.0.0-SNAPSHOT, must have -SNAPSHOT if the plugin version is x.x.x.qualifierPackaging:eclipse-plugin. This element is not in the list (jar/pom/war) because of the incompatible oftycho,mavenandeclipse, so just type it in although it will be a warning
Finish
Configure pom.xml to recognize the parent pom.xml for Maven builds​
- Open
pom.xmlininstitution.gama.pluginsName - In the tab
Overview,Parentsection, type in:Group id:org.gamaArtifact id:gama.experimental.parentVersion:2024-07-SNAPSHOTreplace by the gama version you want your plugin to be deployed for, followed by-SNAPSHOTRelative path:../gama.experimental.parent
- Save
Update maven cache in eclipse (optional)​
It will fix this compilation error Project configuration is not up-to-date with pom.xml. Right click on the project and in the contextual menu select: Maven->Update Project... or use Quick Fix.
Create a feature for the plugin​
Create new feature​
New->Project-> type in :feature-> SelectFeature Project- Set:
Project name:institution.gama.feature.pluginsName- Uncheck
use default location, type in:{current git repository}\institution.gama.feature.pluginsName Feature Version:1.0.0.qualifier
- Click
NextInitialize from the plugin list-> check all plugins needed:institution.gama.pluginsName (1.0.0.qualifier)
Finish- Open
feature.xml, in the tabOverview, in theGeneral Informationsection type in:Update Site URL:http://updates.gama-platform.org/experimentalUpdate Site Name:GAMA Experimental Plugins Update Site
Add pom.xml for feature institution.gama.feature.pluginsName:​
- Right click on the feature project ->
Configure->Convert to maven project - Set:
Group id:institution.gama.feature.pluginsNameArtifact id:institution.gama.feature.pluginsNameVersion:1.0.0-SNAPSHOTPackaging:eclipse-feature
Finish
Configure pom.xml to recognize the parent pom.xml for Maven builds​
- Open
pom.xmlin the projectinstitution.gama.pluginsName - In the
Overviewsection in the tabParenttype in:Group id:org.gamaArtifact id:gama.experimental.parentVersion:2024-07-SNAPSHOTreplace by the gama version you want your plugin to be deployed for, followed by-SNAPSHOTRelative path:../gama.experimental.parent
Save
Update maven cache in eclipse (optional)​
It will fix this compilation error Project configuration is not up-to-date with pom.xml. Select: Maven->Update Project... from the project contextual menu or use Quick Fix.
Update p2updatesite​
- Open
gama.experimental.p2updatesite - Tab
Managing the Categories->Add feature->institution.gama.feature.pluginsName