Part 2.1: Generate a new plugin from a Maven archetype template
This guide shows you how to generate a new plugin from a Maven archetype template.
A Maven archetype is used to define the structure of a Funnelback plugin and provides both the file structure and a set of template files required by a plugin.
Using a Maven archetype is the easiest way to setup a new plugin as this will create a new plugin by automatically fetching the current version of the template and running through a setup process that configures all the required options.
Before using this guide ensure that you have installed Java, Apache Maven and IntelliJ on your computer as outlined in part 1: setting up your development environment.
When the Maven command is run it will prompt for a number of required fields.
Open up a terminal and change to the folder that houses all of your plugins. If this is the first time creating a plugin then create a new folder to use for your plugin development. Each plugin that you develop will be in a sub-folder of this.
$ cd my-plugins-directory
Run the maven command.
$ mvn archetype:generate -DarchetypeGroupId=com.funnelback -DarchetypeArtifactId=plugin-archetypes -Dversion=1.0.0
The archetype will ask you a series of questions which are used to generate the files for your new plugin.
See: Archetype questions for detailed information on each of the questions asked by the archetype generator.
For this tutorial we are going to create a plugin that cleans off a prefix from your search result titles. Answer the questions as follows:
This plugin will be implementing the search lifecycle interface (it’s implementing a hook script). No other plugin interfaces are required so we answer false when the archetype asks about these interfaces.
Define value for property 'gatherer': false
Define value for property 'facets': false
Define value for property 'indexing': false
Define value for property 'searchLifeCycle': true
Define value for property 'filtering': false
Define value for property 'jsoup-filtering': false
Define value for property 'search-servlet-filtering': false
Define value for property 'start-url-provider': false
Define value for property 'groupId': com.example.plugin
Define value for property 'artifactId': title-prefix
Define value for property 'plugin-name': Modify title prefix
Define value for property 'plugin-description': Use this plugin to modify the prefix of search result titles
Define value for property 'archetypeVersion': LATEST
Define value for property 'runs-on-datasource': false
Define value for property 'runs-on-result-page': true
Define value for property 'package': com.example.plugin.titleprefix
Once you have worked through all the questions you are asked to confirm your selections then Maven will generate a new folder generated called
title-prefix, as a sub-folder to your
my-plugins-directory. This folder contains all the files required to develop and package your plugin.
The next tutorial shows how to import this project into IntelliJ and covers the anatomy of a plugin.