Migrating to ImgLib2 - dependency problems

Hi all,

I wanted to try curve fitting using ImgLib2 and have been running into problems that seem to be Maven related. The class I want to use, LevenbergMarquardtSolver, is in the artifact imglib2-algorithm-gpl, but when I add this artifact as a depency to my pom file in Eclipse I get “Missing artifact net.imglib2:imglib2-algorithm-gpl:jar:0.1.3”. Somehow this artifact is however in my local repository, but if I run a very basic program using the LevenbergMarquardtSolver class it throws a NoClassDefFoundError: Jama/Matrix, which has indeed not been pulled in as a depency.

What I have also tried is, following the example of imglib2-tutorials (which is working for me inside Eclipse), set pom-imglib2 as a parent for this project. I have also tried to manually pull in some other ImgLib2 artifacts as depencies, but it always complains that it can’t find imglib2-algorithm-gpl, or imglib2-algorithm for that matter. And if Eclipse adds this as a “referenced library”, I get the jama.Matrix error as above.

I hope I haven’t overlooked some obviously available instructions, but I’d like to ask what is the correct way of doing what I just described. Thanks.

David

Never mind. I needed to specify the repository in the pom as below, as the imglib2-algorithm*, etc. artifacts aren’t in the default repositories. I had assumed imglib2-pom as parent would take care of this, but no. Now it’s working.


	
		imagej.public
		http://maven.imagej.net/content/groups/public
	

Indeed, you have to add a <repositories> block, as described on the Maven page of the ImageJ developer docs.

The main reason is that declaring additional <repositories> in POMs deployed to Maven Central is considered bad practice. From Sonatype’s Central requirements page:

We discourage the usage of <repositories> and <pluginRepositories> and instead publish any required components to the Central Repository. This applies for your own components as well as for 3rd party artifacts.

Thank you Curtis. This page about Maven must have somehow escaped my attention and I have still a lot to learn on that front. Now looking forward to smooth sailing into the fascinating world of ImgLib2 :smile:

1 Like

Ha, I hope that is the case for you! :wink: But ImgLib2 does have a nontrivial learning curve, so ask away here on the forum if you get stuck. And definitely go through the ImgLib2 Examples and ImgLib2 paper if you haven’t already.

1 Like

It will be a tough journey at the beginning, but it is absolutely worth it. ImgLib2 is great and I’m happy to help you if you face any problems!

2 Likes