[ImageJ-devel] KNIP dynamic ImageJ plugin loading
Johannes Schindelin
Johannes.Schindelin at gmx.de
Wed Jun 13 16:30:32 CDT 2012
Hi Mike,
On Wed, 6 Jun 2012, Michael Doube wrote:
> I started a document at the last hackathon but have lacked time to work
> on it since then: please feel free to add your insight to it:
>
> http://developer.imagej.net/writing-imagej-plugins
>
> The idea is to make it as easy as possible to start writing plugins in
> Eclipse: ideally there should be minimal stuff to configure so you can
> concentrate on learning the new APIs. Because most plugin developers
> won't be ImageJ developers, there's no sense in forcing them to have
> full repositories of those projects. It's much leaner to have the
> snapshot JAR to develop against.
To keep you updated on the progress in this regard:
1) To solve the issue with Eclipse not running the annotation processors
as mandated by the Java specification, I managed to get code working that
can quickly detect at startup when the annotation processor needs to be
run. The last part I need to finish is to edit the Eclipse configuration
(if it is detected that we're really running inside Eclipse) to at least
trigger the annotation processing after a Project>Clean. The progress can
be seen in the 'eclipse-helper' branch in our repository.
2) Since Eclipse 3.7, Maven support is shipped by default. Netbeans and
IntelliJ already do that, so I think the way we'll go forward is to have
File>New Plugin write a pom.xml and set up a .java file from a template.
This pom.xml will have the scijava pom as parent so you do not need to
bother downloading .jar files or setting up Git submodules or some such at
all; this is what Maven excels at.
3) There is a ticket (sorry, I cannot look it up, am offline on an airport
writing this) for File>New Plugin (Eclipse). I am tending now to have a
unified user interface for all ways to make a new plugin; the dialog will
not only ask for the class name but also whether to open this in Eclipse,
Netbeans, IntelliJ or the Script Editor (or any other program which can
cope with Maven configurations). A first stab at opening stuff in Eclipse
can be seen attached to this mail (a Beanshell script that can start
Eclipse given its path from Java); hopefully I'll manage to tell Eclipse
to add a project to the current workspace and to open a given file right
away.
4) it should be easy to start the JVM (and by extension, ImageJ) with
options so that Eclipse's debugger can attach to it. I still have to find
out which those options are and I need to figure out a good UI to
configure ImageJ so that it restarts in that mode (I do think that a
restart is required, though).
If you can help me with any of this, I will be very thankful.
Ciao,
Johannes
-------------- next part --------------
import java.io.File;
eclipseRoot = new File(System.getProperty("user.home") + "/eclipse/");
addClassPath(new File(eclipseRoot, "plugins/org.eclipse.osgi_3.7.2.v20120110-1415.jar").getPath());
/*
for (File file : new File(eclipseRoot, "plugins").listFiles())
if (file.getName().endsWith(".jar"))
addClassPath(file.getAbsolutePath());
else if (file.isDirectory())
for (File file2 : file.listFiles())
if (file2.getName().endsWith(".jar"))
addClassPath(file2.getAbsolutePath());
*/
import org.eclipse.core.runtime.adaptor.EclipseStarter;
import java.util.HashMap;
import java.util.Map;
Map properties = new HashMap();
properties.put("osgi.install.area", eclipseRoot.getPath());
properties.put("osgi.syspath", eclipseRoot.getPath() + "/plugins");
properties.put("osgi.configuration.area", eclipseRoot.getPath() + "/configuration");
properties.put("osgi.parentClassloader", "fwk");
EclipseStarter.setInitialProperties(properties );
EclipseStarter.startup(new String[] {}, null);
c = EclipseStarter.run(null);
print(c);
// todo: EclipseStarter.shutdown();
More information about the ImageJ-devel
mailing list