Plugins written in Groovy not seen by PluginService


I wrote a small plugin in Groovy. I built by using maven and deployed into jars directory in ImageJ. Unfortunately, ImageJ does not see this plugin, despite @Plugin annotation. I also do not see the META-INF/json folder inside the generated jar.

Am I missing something?

You can check my POM here:

Thanks for help!


So just some more clarification,

I am able to run the command from the main() class (but only when it’s in a Java file, not Groovy file - see LegacyService and Groovy) and I am able to run it from python script:

# @CommandService command
from eu.hassanlab.rdnwdp import PreProcessing, True)

but the menu item does not get added (using @Plugin(menuPath="something")) nor I can run it using ImageJ-macosx --run PreProcessing "options"

# fiji --run PreProcessing "[inputFolder='test',dataFormat='HDF5']"
[INFO] Overriding Dump Stack; identifier: command:org.scijava.plugins.commands.debug.DumpStack; jar: file:/Applications/
[WARNING] Ignoring invalid argument: --run
Error while executing the main() method of class 'net.imagej.Main':
java.lang.UnsupportedOperationException: Attempting to read or write from a There is no source to operate on.
	at io.scif.formats.KontronFormat$Checker.isFormat(
	at io.scif.AbstractChecker.isFormat(
	at net.imagej.legacy.DefaultLegacyHooks.interceptOpenImage(
	at ij.IJ.openImage(
	at net.imagej.legacy.IJ1Helper.openImage(
	at net.imagej.legacy.LegacyCommandline$Filename.handle(
	at org.scijava.console.DefaultConsoleService.processArgs(
	at net.imagej.legacy.LegacyConsoleService.processArgs(
	at org.scijava.AbstractGateway.launch(
	at net.imagej.Main.main(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at net.imagej.launcher.ClassLauncher.launch(
	at net.imagej.launcher.ClassLauncher.main(

Now I have added a java class, but it still is not included in the menu. No idea what am I doing wrong here!

Wow, sorry I never saw this thread until now, @radoslaw.ejsmont.

Regarding writing SciJava plugins in Groovy: it seems that Groovy does not support Java annotation processing. There is an open issue for it but I think it would be a difficult project to implement. For SciJava only (i.e. only the @Plugin annotation), we could perhaps implement a less general solution.

For Kotlin, there is an annotation processor (kapt), so that is an option for people who want an alternative to Java’s verbosity.

You were on the right track to look for META-INF/json/org.scijava.plugin.Plugin in the JAR file. If that is missing, then there is no hope of it being present in the menu. If that file is present and contains your plugin metadata (you can use a text editor to check), then it should be discovered at runtime.

Probably you need to pass the --ij2 flag as well. See the Scripting Headless page.

1 Like