Plugins written in Groovy not seen by PluginService

Hi,

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: https://github.com/rejsmont/rdn-wdp-groovy/blob/master/pom.xml

Thanks for help!

Radek

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
command.run(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/Fiji.app/jars/scijava-plugins-commands-0.2.3.jar
[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 io.scif.io.VirtualHandle. There is no source to operate on.
	at io.scif.io.VirtualHandle.read(VirtualHandle.java:83)
	at io.scif.io.RandomAccessInputStream.read(RandomAccessInputStream.java:437)
	at io.scif.formats.KontronFormat$Checker.isFormat(KontronFormat.java:124)
	at io.scif.AbstractChecker.isFormat(AbstractChecker.java:93)
	at io.scif.services.DefaultFormatService.getFormatList(DefaultFormatService.java:342)
	at io.scif.services.DefaultFormatService.getFormat(DefaultFormatService.java:317)
	at io.scif.services.DefaultDatasetIOService.canOpen(DefaultDatasetIOService.java:83)
	at io.scif.io.DatasetIOPlugin.supportsOpen(DatasetIOPlugin.java:65)
	at org.scijava.io.IOService.getOpener(IOService.java:55)
	at net.imagej.legacy.plugin.DefaultLegacyOpener.open(DefaultLegacyOpener.java:131)
	at net.imagej.legacy.DefaultLegacyHooks.interceptOpenImage(DefaultLegacyHooks.java:340)
	at ij.IJ.openImage(IJ.java)
	at net.imagej.legacy.IJ1Helper.openImage(IJ1Helper.java:1135)
	at net.imagej.legacy.LegacyCommandline$Filename.handle(LegacyCommandline.java:163)
	at org.scijava.console.DefaultConsoleService.processArgs(DefaultConsoleService.java:102)
	at net.imagej.legacy.LegacyConsoleService.processArgs(LegacyConsoleService.java:81)
	at org.scijava.AbstractGateway.launch(AbstractGateway.java:96)
	at net.imagej.Main.main(Main.java:55)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at net.imagej.launcher.ClassLauncher.launch(ClassLauncher.java:279)
	at net.imagej.launcher.ClassLauncher.run(ClassLauncher.java:186)
	at net.imagej.launcher.ClassLauncher.main(ClassLauncher.java:77)

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