Friday, November 24, 2006

Maven2 : Evil or Not?

Guys, I have very little time to blog these days, too much work, but let me do a complaint.

Since my colleague Gianugo talked me about it, I've always been a strong supporter of Maven2.

It is true that it is a kind of black magic.
It is true that it has a (very) poor dependencies conflict resolver.
But hey, it let you manage your build process with very little configuration effort, has a good convention over configuration approach, let you centralize your dependencies, has a wide community and ... is cool (should I have mentioned this as first?).
So, since I started to use it, I have to say it helped me very much in speeding up my build management process.

But please, guys: can someone tell me why there are tests that succeed when executed by my preferred IDE, and fail when executed by Maven2?

Weeks ago I've already discovered serious problems between Maven2 and static inner classes, but now I can't really find any workaround.

Some times ago my colleague Ugo Cei started blogging about the question: Goolge: evil or not?

Now it is my time: Maven2 : evil or not?

9 comments:

valerio said...

of course i can answer your questions: your tests fail when launched within maven reactor (and surefire isolated classloaders) because very probably you're not being independent from the environment in which tests are executed.

I passes through that my self sometimes ago: i found out the problem was that i was using something like: File testFixture = new File("somepath/to/testFixture");

while instead i should have used MyTest.class.getResourceAsStream("...");

being able to write completely cross-environment tests is a very hard task, i must admit.

Sergio Bossa said...

Hi Valerio,

thanks for your answer.

My resources are properly loaded through the class resource loader, so this is not the problem.

Indeed, I've found the problem: my project has many sub-modules, and there was a not up-to-date installed dependency to another sub-module.
This is IMHO another Maven2 weirdness: internal dependencies should be resolved locally, rather than by looking at installed artifacts.

What do you think? Is there maybe a way to do that?

Cheers,

Sergio B.

valerio said...

hi Sergio,
if you need to resolve your dependencies within your module hierarchy, one way to do that is to declare them to a snapshot version, and setup your continuus integration machine to check for updates everytime it launches a build. this is very easy with continuum, as it integrates with maven.

out of curiosity: how big is your module tree? the only maven project i've found so far with a module depth level higher than 2 is cargo..how about yours?

Sergio Bossa said...

Hi Valerio,

I know that snapshot thing, but even with that, Maven2 still looks for dependencies *into* the local repository: so it doesn't solve my issue.

My module depth is quite small: just one level!

Cheers,

Sergio B.

Anonymous said...

this might be of interest for you:

http://docs.codehaus.org/display/MAVEN/Improves+Modules+Definition

Anonymous said...

>internal dependencies should be >resolved locally, rather than by >looking at installed artifacts.

launch the tests from the parent pom, and you're done :)

cheers, and happy 2007

Anonymous said...

I have the same kind of mixed fellings about maven2.

I think, I will consider Raven for my next project.

Sergio Bossa said...

Hi Valerio,

thanks for your answers and sorry for the late reply: I'm very busy.

I know that launching tests from parents will also install it with all its children: however, this actually forces me to build from the parent, and this is not what I want to do.

Moreover, thanks for the link: I'll give it a look as soon as I'll have again a normal life with (not many, but still there) spare time.

Cheers!

Sergio B.

P.S. Happy new year to you, too!

Sergio Bossa said...

Hi Jeremy,

thanks for your answer.

I'll take a look at Raven as soon as possible and let know: in the meantime, can you say me why you'd go with Raven (instead of some other tool)?