How to Create a Plugin for JBoss Forge

W/ JBoss Forge

1) Create a new project:

$ new-project --named sampleplugin --topLevelPackage br.eti.fernandoribeiro.sample --projectFolder sample

2) Install the plugin API:

$ plugins setup

3) Create the plugin class:

package br.eti.fernandoribeiro.sample;

import org.jboss.forge.shell.plugins.Alias;
import org.jboss.forge.shell.plugins.Command;
import org.jboss.forge.shell.plugins.Plugin;

@Alias("sample")
public final class SamplePlugin implements Plugin {

  @Command(value = "do-something", help = "Does something")
  public void doSomething() {
  }

}

4) Add the command to the shell as described here.

5) Run the command in JBoss Forge:

$ sample do-something

W/o JBoss Forge

1) Create the plugin class:

package br.eti.fernandoribeiro.sample;

import org.jboss.forge.shell.plugins.Alias;
import org.jboss.forge.shell.plugins.Command;
import org.jboss.forge.shell.plugins.Plugin;

@Alias("sample")
public final class SamplePlugin implements Plugin {

  @Command(value = "do-something", help = "Does something")
  public void doSomething() {
  }

}

2) Create the META-INF/beans.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd" />

3) Add the command to the shell as described here.

4) Run the command in JBoss Forge:

$ sample do-something

You can find more details here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s