[ImageJ-devel] Netbeans and Maven

Curtis Rueden ctrueden at wisc.edu
Tue Jan 15 09:43:01 CST 2013


Hi Gerrit,

I was mostly done (except for "..." sections) with a reply to you
yesterday, before needing to leave work for the day. Since then, Johannes
has replied, so my response is now rather redundant. But I am sending it
now anyway to supplement Johannes's reply.


> 1- what does the pom version mean, and which version should I use, I
> found different numbers in the examples.

The pom.xml of minimal-ij1-plugin inherits from a parent called
pom-scijava. This parent POM defines and configures many things so that the
POMs of individual plugin projects are shorter (i.e., so they don't have to
repeat things).

The version of pom-scijava (1.27 as of this writing) indicates the version
of that parent POM. We occasionally improve the parent POM, adding and
tweaking it. When we do so, its version increases. I suggest leaving the
version that same as what's in minimal-ij1-plugin, since that refers to the
latest version. Future 1.x versions will be backwards compatible, so if you
later notice that we have updated minimal-ij1-plugin to e.g. 1.43, you can
(optionally) update your plugin to that version as well.

The version of minimal-ij1-plugin itself (1.0.0 as of this writing) is the
version of your plugin. This string is appended to the JAR file name (e.g.,
minimal-ij1-plugin-1.0.0.jar), so that you can differentiate between
multiple versions of your plugin. Use whatever versioning scheme you want.

However, once you become more comfortable with Maven, I suggest using a
SNAPSHOT version during development [1], and a release (i.e., non-SNAPSHOT)
version when distributing your plugin. The reason is to avoid two different
JAR files both called "my-plugin-1.2.3" but with different contents. (This
is part of what Maven calls *build reproducibility*.)


> 2- how is the imagej version determined
> (<version>${imagej1.version}</version>) ?

The string "${imagej1.version}" is a property that gets replaced with the
actual value. This value is defined in the pom-scijava parent
configuration. Currently the value is "[1.45s,)" which means "the latest
release version you can find equal to or greater than 1.45s."

Browse the latest pom-scijava at:

https://github.com/scijava/scijava-common/blob/master/pom-scijava/pom.xml

Browse the available versions of ImageJ 1.x at:
    http://maven.imagej.net/content/repositories/releases/net/imagej/ij/

As of this writing, 1.47h is the latest available version, so that's the
one Maven will use with your plugin.


> 3- During build I see the following message: Property
> 'imagej.app.directory' unset; Skipping copy-jars
> So it must be possible to place the jar into my own imagej installation,
how?

This is part of the new imagej-maven-plugin (enabled for you by
pom-scijava). As you suspected, it copies your plugin's JAR file to your
ImageJ plugins folder. But you have to specify where:

    mvn -Dimagej.app.directory=/Applications/ImageJ.app

One way to do that in NetBeans is to right-click your project, select
Custom > Goals... which brings up the Run Maven dialog box. Then specify
"install" for the Goals and
"-Dimagej.app.directory=/Applications/ImageJ.app" for the Properties.

I haven't tested this though; the imagej-maven-plugin is very new and we
are still finalizing how it will work. So please proceed with that in mind.


> 4- During run an imagej jar from ~/.m2.... is started, is this only
> for test/debug? how to use my own imagej?

...


> 5- The process_pixels application does not quit properly, I have to
> stop it from netbeans.

...


> 6- My software is dependent from other plugins, such as particle8 from
> Gabriel Landini's Morphology, can/is this incorporated in the imagej
> maven repository?

...


> 7- In my ant script I'm using a call to svnversion, in order to place
> the latest build number and date in the about box. Can this be done in
> maven?

In general, you can call any needed Ant functionality using the
maven-antrun-plugin [2]. However, for your requirement here, you won't need
it.

The pom-scijava parent uses the buildnumber-maven-plugin to embed the SCM
revision and date in the JAR manifest. You can enable this behavior by
adding the following lines to your POM:

    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
      </plugin>
    </plugins>

Then, your About dialog box can access the information from the JAR
manifest using the java.util.jar.Manifest class.

You can see how we use it in ImageJ2 here:

https://github.com/imagej/imagej/blob/7ffe00ef/core/core/src/main/java/imagej/util/Manifest.java

Or you can use that ImageJ2 Manifest class directly if you are willing to
add a dependency to ij-core to your POM:

    <dependencies>
      <dependency>
        <groupId>${imagej.groupId}</groupId>
        <artifactId>ij-core</artifactId>
        <version>${imagej.version}</version>
      </dependency>
    </dependencies>

For more information about Maven, see:
    http://developer.imagej.net/learning-maven
    http://maven.apache.org/guides/getting-started/index.html

Regards,
Curtis

[1]
http://stackoverflow.com/questions/5901378/what-exactly-is-a-maven-snapshot-and-why-do-we-need-it
[2] http://maven.apache.org/plugins/maven-antrun-plugin/


On Mon, Jan 14, 2013 at 2:21 PM, Polder, Gerrit <gerrit.polder at wur.nl>wrote:

> sorry for crosspost, asked this already on the ImageJ list, but Wayne
> directed me to here.
>
> I am using netbeans with ant as the building system quite some time now
> (on Mac OS X).
> During the last developer conference there was a strong emphasis on maven
> as build/dependency tool, so I decided to give it a try.
> I started with the process_pixels example which compiles and runs nice,
> but I have some questions.
> Sorry if these are dumb questions, but I scanned through the documentation
> and didn't find answers quickly.
>
> 1- what does the pom version mean, and which version should I use, I found
> different numbers in the examples.
> 2- how is the imagej version determined
> (<version>${imagej1.version}</version>) ?
> 3- During build I see the following message: Property
> 'imagej.app.directory' unset; Skipping copy-jars
> So it must be possible to place the jar into my own imagej installation,
> how?
> 4- During run an imagej jar from ~/.m2.... is started, is this only for
> test/debug? how to use my own imagej?
> 5- The process_pixels application does not quit properly, I have to stop
> it from netbeans.
> 6- My software is dependent from other plugins, such as particle8 from
> Gabriel Landini's Morphology, can/is this incorporated in the imagej maven
> repository?
> 7- In my ant script I'm using a call to svnversion, in order to place the
> latest build number and date in the about box. Can this be done in maven?
>
> thanks a lot,
> Gerrit.
>
>
>
>
>
> _______________________________________________
> ImageJ-devel mailing list
> ImageJ-devel at imagej.net
> http://imagej.net/mailman/listinfo/imagej-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20130115/6d31a4e6/attachment-0001.html>


More information about the ImageJ-devel mailing list