The main()
method of this class creates the plugins.config
file for a given plugins project, which is
to be included in the associated JAR file. The execution is to be triggered during the Maven build or manually by
mvn exec:java -Dexec.mainClass="imagingbook.pluginutils.PluginsConfigBuilder"
(at the root of a plugins project). The format of the entries in plugins.config
have the following
structure:
menu-level, "plugin-name", package.classnamefor example:
Plugins>Binary>Regions, "Convex Hull Demo", Binary_Regions.Convex_Hull_Demo
Note that, technically, menu paths may be more than 2 levels deep, but this does not seem useful.
Plugin classes (implementing PlugIn
or PlugInFilter
) may be annotated with IjPluginPath
and
IjPluginName
to specify where in ImageJ's menu tree and by which name the plugin should be installed. This
information is stored in the plugins.config
file at the root of the associated project, which is
automatically added to the project's output JAR file during the Maven build. Example:
// file MySuperPlugin.java import ij.plugin.filter.PlugInFilter; import imagingbook.pluginutils.annotations.IjPluginName; import imagingbook.pluginutils.annotations.IjPluginPath; ... @IjPluginPath("Plugins>Mine") @IjPluginName("Super Plugin") public class MySuperPlugin implements PlugInFilter { // plugin code ... }
In this case, plugin MySuperPlugin
should be installed in ImageJ's menu tree as
Plugins > Mine > Super Plugin
By default (i.e., if no annotations are present), plugins in the default package are installed at the top-level of
'Plugins' whereas plugins inside a named package are installed in 'Plugins>package-name' (see below). A
IjPluginPath
annotation may also be attached to a whole package in the associated package-info.java
file. The following example specifies Plugins>Binary Regions
as the default menu path for all plugins in
package Binary_Regions
:
// file Binary_Regions/package-info.java @IjPluginPath("Plugins>Binary Regions") package Binary_Regions; import imagingbook.pluginutils.annotations.IjPluginPath;
Individual plugins may override the menu path specified for the containing package, as summarized below:
Plugin path priority rules summary:
- Value of a
@IjPluginPath
annotation at class level (always overrules if exists). - Value of a
@IjPluginPath
annotation at package level (if exists). -
DefaultMenuPath
+ ">" + package-name if the plugin is inside a named package. -
DefaultMenuPath
if the plugin is in the (unnamed) default package.
Plugin entry priority rules summary:
- Value of
IjPluginName
annotation at class level (if exists). - Simple name of the plugin class.
Note that, in general, ImageJ uses the information in file plugins.config
only for plugins loaded from a JAR file!
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncollectPluginClasses
(String rootPath) boolean
isIjPlugin
(Class<?> clazz) static void
Method to be called from the command line.
-
Field Details
-
DefaultMenuPath
-
ConfigFileName
-
INFO
-
VERBOSE
-
ReplaceUndescoresInClassNames
-
ReplaceUndescoresInPackageNames
-
-
Method Details
-
collectPluginClasses
-
isIjPlugin
- Parameters:
clazz
- aClass
object- Returns:
- true if a plugin type
-
main
Method to be called from the command line. Builds the
plugins.config
file from the.class
files found in the specified build directory and stores the file in the same directory. Takes two (optional) arguments:- The project's build (output) directory (where .class files reside).
- The project's Maven artifact id.
- Parameters:
args
-args[0]
: project build (output) directory,args[1]
: project artefact id
-