Skip to content

Part 6: Releasing a Plugin

Warning

This tutorial is deprecated, and will be rewritten to account for JEB 4 API changes.

JEB Plugin Development Tutorial part 6/8

When your plugin is ready, you may be looking into some way to share it. It is not convenient to hand out classfiles, not to mention changing Classpath and Classnames in the JEB Options panel. The solution is to package your plugin: this page shows you how to build a jar file containing your JEB plugin.

Ant Build File#

First, make sure to have a JEB_HOME environment variable pointing to your JEB directory. Then, use the following Ant build.xml file to build the sample JavaScript plugin.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<project basedir="." default="build" name="jebplugin">
    <property name="jebjar" value="${env.JEB_HOME}/bin/cl/jeb.jar"/>
    <property name="jebpath" value="/home/clucas/jeb-2.0.6.201508260620/bin/cl/jeb.jar"/>
    <property name="outfile" value="out/JebJavascriptPlugin.jar"/>
    <property name="entryclass" value="com.jeb.sample.JavascriptPlugin"/>

    <property name="extcp_build" value="lib/js.jar"/>
    <property name="extcp_manifest" value="lib/js.jar"/>

    <target name="build" depends="compile,package"/>

    <target name="compile">
        <delete dir="bin"/>
        <mkdir dir="bin"/>
        <javac debug="true" debuglevel="source,lines,vars"
               destdir="bin" includeantruntime="false" source="1.7" target="1.7">
            <src path="src"/>
            <classpath>
                <pathelement location="${jebpath}"/>
                <pathelement path="${extcp_build}"/>
            </classpath>
        </javac>
    </target>

    <target name="package">
        <delete file="${outfile}"/>
        <jar destfile="${outfile}">
            <manifest>
                <attribute name="Class-Path" value="${extcp_manifest}"/>
                <attribute name="JebPlugin-entryclass" value="${entryclass}"/>
            </manifest>
            <fileset dir="bin"/>
            <fileset dir="." includes="README.md"/>
        </jar>
    </target>

</project>

Building the Plugin#

You can run the build.xml directly from eclipse or execute the Ant command.

It will generate a jar which has 2 specific entries in the manifest:

  • Class-Path to indicate the required external libraries.
  • JebPlugin-entryclass to indicate the classname, ie your plugin entry-point

Copy both JebJavascriptPlugin.jar and js.jar to your plugin folder. You can remove the classpath and classnames entries related to JavascriptPlugin and js.jar.

Note

The best approach is to have one project per plugin.

Assignment: Split the project and generate JavascriptPlugin.jar and HashJavascriptPlugin.jar. Remove all classpaths and classnames to check that it works.

Generic Build Template#

The following Ant template can be customized for your own plugins needs:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<!-- Sample Ant build file used to build and package a JEB plugin.
- Requirements: set up the JEB_HOME environment variable to point to your
JEB installation folder.
- Customize the outfile, entryclass, extcp_build, and extcp_manifest properties. -->

<project basedir="." default="build" name="jebplugin">

    <fail message="Set the plugin version number: ant -Dversion=x.y.z">
      <condition>
        <not>
          <isset property="version"/>
        </not>
      </condition>
    </fail>

    <echo message="Plugin version: ${version}"/>

    <property environment="env"/>
    <echo message="JEB_HOME: ${env.JEB_HOME}"/>

    <property name="jebjar" value="${env.JEB_HOME}/bin/cl/jeb.jar"/>
    <echo message="JEB Core expected at location: ${jebjar}"/>

    <fail message="Please set JEB_HOME environment variable to point to your JEB installation folder">
      <condition>
        <not>
          <available file="${jebjar}"/>
        </not>
      </condition>
    </fail>

    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.7"/>
    <property name="source" value="1.7"/>

    <!-- Mandatory properties -->
    <property name="outfile" value="CUSTOMIZE"/>
    <property name="entryclass" value="CUSTOMIZE"/>
    <!-- External libraries, for build process (semi-colon separated) -->
    <property name="extcp_build" value=""/>
    <!-- External libraries, for Manifest (space separated) -->
    <property name="extcp_manifest" value=""/>

    <target name="build" depends="clean,compile,package"/>
    <target name="audit" depends="clean,compile-audit"/>

    <target name="clean">
        <delete dir="bin"/>
        <mkdir dir="bin"/>
    </target>

    <target name="compile">
        <delete dir="bin"/>
        <mkdir dir="bin"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin"
               includeantruntime="false" source="${source}" target="${target}" encoding="UTF-8">
            <src path="src/main/java"/>
            <classpath>
                <pathelement location="${jebjar}"/>
                <pathelement path="${extcp_build}"/>
            </classpath>
        </javac>
    </target>

    <target name="package">
        <delete file="${outfile}"/>
        <jar destfile="${outfile}">
            <manifest>
                <attribute name="Class-Path" value="${extcp_manifest}"/>
                <attribute name="JebPlugin-entryclass" value="${entryclass}"/>
                <attribute name="JebPlugin-version" value="${version}"/>
            </manifest>
            <fileset dir="bin"/>
            <!-- copy resources -->
            <fileset dir="src/main/java" excludes="**/*.java"/>
            <fileset dir="." includes="README.md"/>
        </jar>
    </target>

</project>