This is an example Maven project implementing an ImageJ 1.x plugin that calls the Bio-Formats library.
It was adapted from the example-legacy-plugin project.
It is intended as a starting point to develop new ImageJ 1.x plugins in an IDE of your choice. You can even collaborate with developers using a different IDE than you.
-
In Eclipse, for example, it is as simple as File>Import...>Existing Maven Project.
-
In NetBeans, it is even simpler: File>Open Project.
-
The same works in IntelliJ.
-
If jEdit is your preferred IDE, you will need the Maven Plugin.
Die-hard command-line developers can use Maven directly by calling mvn
in the project root.
However you build the project, in the end you will have the .jar
file
(called artifact in Maven speak) in the target/
subdirectory.
To copy the artifact into the correct place, you can call
mvn -Dimagej.app.directory=/path/to/ImageJ.app/
.
This will not only copy your artifact, but also all the dependencies. Restart
your ImageJ or call Help>Refresh Menus to see your plugin in the menus.
Developing plugins in an IDE is convenient, especially for debugging. To that
end, the plugin contains a main
method which starts ImageJ and runs the
plugin. See also
this page
for information how ImageJ makes it easier to debug in IDEs.
Either
git clone git://github.com/imagej/example-bio-formats-legacy-plugin
, or- unpack https://github.com/imagej/example-bio-formats-legacy-plugin/archive/master.zip
Then:
- Edit the
pom.xml
file. Every entry should be pretty self-explanatory. In particular, change- the artifactId (NOTE: should contain a '_' character)
- the groupId, ideally to a reverse domain name your organization owns
- the version (note that you typically want to use a version number ending in -SNAPSHOT to mark it as a work in progress rather than a final version)
- the dependencies (read how to specify the correct groupId/artifactId/version triplet here)
- the developer information
- the scm information
- Remove the
Simple_Read.java
file and add your own.java
files tosrc/main/java/<package>/
(if you need supporting files -- like icons -- in the resulting.jar
file, put them intosrc/main/resources/
) - Edit
src/main/resources/plugins.config
- Replace the contents of
README.md
with information about your project.
If you cloned the example-bio-formats-legacy-plugin
repository, you probably
want to publish the result in your own repository:
- Call
git status
to verify .gitignore lists all the files (or file patterns) that should be ignored - Call
git add .
andgit add -u
to stage the current files for commit - Call
git commit
orgit gui
to commit the changes - Create a new GitHub repository
git remote set-url origin [email protected]:<username>/<projectname>
git push origin HEAD
- Go to Run Configurations...
- Choose Maven Build
- Add the following parameter:
- name:
imagej.app.directory
- value:
/path/to/ImageJ.app/
- name:
This ensures that the final .jar
file will also be copied to your ImageJ
plugins folder everytime you run the Maven Build