#Example Extension/Extension Skeleton
This maven project is a sample extension layout that provides a basic framework, with all the proper checks in place as well as a few utilities to get you started. It is built with NetBeans and Maven in mind, although other configurations might be possible, with less functionality (compile time errors, etc).
##Usage ###Standalone use This method makes for a simpler way to get up and running, but requires you to clone the original repo for each project.
- Clone this repo from where it's hosted.
- Remove the
.git
folder. Can't skip this one! - Run
mvn clean
from the pom directory. - ...?
- Profit!
###Archetype installation This method adds a permanent copy of the template in your maven repo, allowing for quick replication across new projects.
- Clone this repo from where it's hosted.
- Run
mvn archetype:create-from-project
from the pom directory. - Change to the
target/generated-sources/archetype/
directory, which is where the archetype resides. - Run
mvn clean install
from this directory. - Tell maven to crawl it's local repo for available archetypes by running
mvn archetype:crawl
from anywhere. - If you use an IDE with maven integrated, ask it to refresh it's cache.
- Netbeans: Go to Tools, Options, select the Java icon at the top, then the Maven tab, select Index in the
Categories
list, and finally press theIndex Now
button.
Once the archetype is installed, you can use the New Project
option.
- From the New Project wizard window, select
maven
from the categories pane - Select
Project from Archetype
in the Projects pane. - Wait for the list to populate.
- In the Search box, type
chextension-archetype
. - Select
chextension-archetype
in the Known Archetypes list, and press Next. - Fill out the data required then click Finish.
- ...?
- Profit!
Currently, you will need to rename the project from CHExtension. This is only visible/used in an IDE, and has no affect on the end result.
More info on creating (and thus updating) an archetype from an existing maven project can be found here.
##After project setup After your project is setup and ready to be developed on, there are a few things that need to be adjusted, before we get going.
###/pom.xml This file, as usual, is what defines the build process for your extension, including special directives and procedures, and defines what dependencies are needed. There are a few helpful comments, so be sure to read thru it.
Most notably, there is a helpful embedded version system, tied into git, if you use it. You need to have the project committed to an initialized git repo, and un-comment the relevant <scm>
and <plugin>
blocks for this to function correctly.
The project defaults to the more lenient MIT
license. A LICENSE
file is not provided for you, but the pom declares MIT
as the default license. Feel free to change this!
The exec-maven-plugin
and maven-processor-plugin
build plugins aren't necessary, but they provide automatic verification and caching for when the extension is being compiled. Removing these is not advised, and could cripple startup time in larger projects as well as potentially cause errors at runtime.
###/src/main/java/some/package/here/LifeCycle.java This class is what aids in managing life events of your extension. Starting up, shutting down, reloading aliases, and some features are handled here.
First off, we need to change the identification tag for this extension, to "personalize" your extension. You will need to change exampleextension
in the @CHExtension
line to something that identifies your extension. For example, an extension exposing IRC functionality might say @MSExtension('CHIRC')
. When this extension is referenced to in logs, etc, this is the name that will be used to identify it.