Create a new plugin project
Before you start, ensure you have set up an appropriate development environment for creating plugins. |
A plugin is created using a command line tool that creates a new empty plugin project from a template.
The source code for a plugin must be set up using a pre-defined folder structure that includes a set of standard files and plugin-specific files.
This tool creates the folder structure provides basic java files required to start working on a new plugin.
The template is defined as a Maven archetype template and will always produce a folder and file structure based on the current version of the plugin framework.
When you create a new plugin you need to have the following information:
Plugin descriptors
The following descriptors must be defined when creating a new plugin:
- Artifact ID
-
The
artifactId
defines the name of the plugin. The name should be concise but describe the function of the plugin. Note: Avoid using the word "plugin" in the ID, it doesn’t provide any value and makes names unnecessarily longer. - Group ID
-
A
groupId
defines your organization/subgroup. This should be based on your organization’s domain name. e.g. If your organization is ExampleORG, and it has a domain name ofexample.com
then you should usecom.example.plugin
. - Package name
-
The package name identifies the plugin in Java. It should follow the format
GROUP-ID.ARTIFACT-ID
. - Plugin name
-
A human-readable name for the plugin, for display in the plugin administration pages in Funnelback.
- Plugin description
-
A short description of the plugin, also be shown in the plugin administration pages.
Interface templates
You also need to know what functionality your plugin will implement. If you provide these at creation time the template will create the relevant java files that include required imports and methods to make it easy to start writing your code.
- gatherer
-
Only works for a custom data source. Lets you create a custom gatherer, which will get documents in unique ways.
- filtering
-
Lets you create a document filter or HTML document filter for modifying documents before they are indexed.
- indexing
-
Lets you hook into different parts of the indexing process; providing metadata mappings, external metadata mappings, gscopes or to kill documents
- facets
-
Lets you provide faceted navigation configuration.
- search-servlet-filtering
-
Lets you hook into the servlet request and response lifecycle by implementing the
SearchServletFilterHook
interface - searchLifeCycle
-
Lets you write code that enables you to manipulate the query processing and search results or provide custom faceted navigation category sorting.
- startUrlProvider
-
Lets you provide logical that will define additional start URLs.
Plugin scope
A plugin can run on a data source and/or a results page. These flags indicate if a plugin applies in a certain scope and will also determine if you can enable the plugin from the search dashboard on a results page or data source.
- runs-on-datasource
-
The plugin can be run on a data source. Plugins that implement the following interfaces should run on a data source:
-
gatherer
-
filtering
-
jsoup-filtering
-
indexing
-
- runs-on-result-page
-
The plugin can be run on a results page. Plugins that implement the following interfaces should run on a results page:
-
searchLifecycle
-
facets
-
search-servlet-filtering
-
Running the command line tool
Change to the folder where you intend to work on all your plugin projects. Each plugin project will be created in a sub-folder of this directory.
Run the following command:
$ mvn archetype:generate -DarchetypeGroupId=com.funnelback -DarchetypeArtifactId=plugin-archetypes -DarchetypeVersion=LATEST
See: Tutorial - Part 2.1: Generate a new plugin from a Maven archetype template