DevPinoy.org
A Filipino Developers Community
   
The Rise of Maven
I was wondering why suddenly there was increased interest in using Maven. Threads are started in PinoyJUG about it. I'm glad it's gaining ground in our local scene.

I started using this tool a few years back when I had to build one of Apache's projects. I just can't remember what project that was. I think that was 3 years ago. I am using it for my open source project LemonSMS.

Anyway, Maven is a tool for building Java projects. It has features like:

- Auto-dependency checking and updating of libraries required by your project
- Automatic generation of documentation in PDF and html
- Automatic generation of your project website
- Continuous integration support
- Multiple project support
- Plus other features you will discover when using it

Official set of features can be seen here.

The auto-dependency checking feature is interesting.It allows you to define the dependency libraries in your project's configuration. The feature is similar to BSD and Gentoo's ports system. With this feature, you avoid  the trouble of downloading the right version of the library your project requires because versions are defined in the configuration as well. This is very useful for medium-to-large sized teams especially if your working on reusable components.

Let's have one scenario. Let's say I am responsible for creating and updating the database access components in my team. My component is being used by different projects that require database functionalty. The ordinary process will be to compile the component into a jar then give copies to other members of the team. Pretty straightforward eh? Yes, it's easy if you have a small team. However, let's say we have 12 team members. So what's the issue? I can still give copies to the other 11 members right? You're correct.

Here's the thing. Let's say I need to update a method in the library and this is affecting all modules coded by the other team members. What I'll do is build the library and have the others use it. But there's this one junior guy who for some reason mixed up copying the correct version to his machine. Now, he can't compile! So he goes to your desk and asks what seems to be the problem. He insists that he copied the correct version. Now you go to your desk and resend your library. It seems that you sent the wrong version. Now, you have to notify the other team members. Isn't that a pain?! How much time was lost? So this is the problem Maven is solving with this feature. It avoids your team to mix up versions of the libraries because the source is central and checking is done on-the-fly.

Another very neat feature of Maven is to automatically create PDF and html documentation. But this is nothing. What's really cool is you can create your project website automatically by just one command. Did you see Maven's website? This was automatically generated using Maven. Don't believe me? Check out all project websites in Apache Jakarta that uses Maven. You'll see the similarity. ;-)

Maven is a pain when you're starting with it but when you get used to it it's a pretty useful tool. Maybe you can start with Maven's 5 minute tutorial and get the feel of it.

Happy Coding!





Posted 03-13-2007 9:44 PM by javazealot
Filed under: ,

Comments

keithrull wrote re: The Rise of Maven
on 03-13-2007 7:39 AM

Very nice introduction to maven!

I agree, maven is a little bit hard to use the frist time.. there is a steep learning curve when using this tool but once you get to understand the richness of it you'll realize that it can do wonders for you project.

jokiz wrote re: The Rise of Maven
on 03-13-2007 10:03 PM

i'm not really a java guy but isn't it that members of the team should have access to the code of the project and they should be able to produce the jars from the mainline of source.

or is this another security restriction issue on the project structure?

lamia wrote re: The Rise of Maven
on 03-13-2007 11:02 PM

Hmmm... I thought maven was just another build tool like ant...

javazealot wrote re: The Rise of Maven
on 03-14-2007 8:50 PM

@keithrull. Yeah it is a neat tool if you use it wisely. Its still up to you to decide if you really need Maven's features. If ant suffices then there's no point of making things complicated especially for simple projects.

@jokiz. Maven is not source control. Developers are still given the option to use their favorite source control like CVS or Subversion. I think you are confused by my example. Anyway, libraries can still be modified by the team. Actually, what you pointed out is one of the reasons you should use Maven. Let's say a few developers updated the library simultaneously, it's even more painful to synchronize versions with others using the library. This is one instance where Maven is useful.

@lamia. This is the common misconception. Maven is not just another build tool. It has more features than ant. Well, this is a big debate since ant fanatics don't want to accept that there are things done easier in Maven. I mean just use the right tool for the job. Use a hammer to drive nails and a screwdriver to drive screws. =)

lamia wrote re: The Rise of Maven
on 03-14-2007 10:31 PM

@javazealot

I see, I happen to be just learning Ant(or rather, getting more used to) and it's always very important for me at an early stage to get acquainted with the right tools that I'll need for the job. It's also very important for me that the technology that I'm going to learn isn't going to be obsolete in a year or so. Thanks for the enlightenment.

jokiz wrote re: The Rise of Maven
on 03-14-2007 11:08 PM

actually i was confused since my frame of reference was visual studio where binary references are automatically updated for dependent projects on build, i was not aware that it was not the same way for java IDE's (without using maven)

alistair wrote Ant vs. Maven
on 03-20-2007 9:08 PM

While comparing Ant to Maven would be like comparing apples to oranges (both get you full, but are different) - Maven incorporates (in fact, relies upon) other conventions or 'best practices'.

What immediately comes to mind, for instance, is the simple act of having a pre-defined project folder structure.

Of course, it may not be ideal or even applicable to 100% of all projects. But contrast this to Ant, where developers are free to define their own folder structure (not to mention dependency management and build process) details.

Sure, Ant'll take care of the 1-2% (throwing a number in the air) cases that won't fit in the Maven folder structure convention - but unless an organization has well-defined guidelines (or an Ant template, heheh, in which case what's wrong with Maven?) for all the above then chances are a new developer starting a project from scratch will use his own conventions (or worse, just hack together an incomprehensible Ant script).

With Maven, any other developers _anywhere_, even outside the organization, will immediately be familiar with the project's file/folder structure, dependency management, build tasks (testing, packaging, deploying) etc. etc. etc.

I've gotten so much into it that for some (smaller) projects I've sometimes included an Ant file that can produce the same (final) build artifact that Maven does, conforming to Maven's conventions.

Copyright DevPinoy 2005-2008