PreviousNext…

This J2EE thing

Screenshot of Maven in actionFinally, I think J2EE is really starting to kick off and mature to the point that nobs like me can use it. I've been knocking out some wee (read: very small, very basic) Java web apps for a little while at work now. Beyond the odd knicker-wettingly stupid scope error in one of my servlets, it’s been going quite well. I’m enjoying the environment (the oft-mentioned MyEclipse), and I’m now even starting to show off — which brings me to build tools. Specifically, Maven.

Now, when I was even wetter behind the ears than I am now, in my copious reading around t’internet, I saw some derogatory comments about Maven. Not having a scooby’s about this tool meant that I thought nothing more of it, and moved on to the next article. However, now that I’ve started to use this beast, I fail to see what the whingeing was about: Maven is actually pretty darn clever.

But Ben, I’m on tenterhooks: what is this thing called “Maven”? I hear one of you ask. Well, pull up a chair and I shall tell you what I know (it won’t take long)…

Maven is often mentioned in the same breath as Ant. Which kind of makes sense. Kind of. Ant is a build tool, and a very capable, extensible and well-known one at that. So why do we need another build tool? Well, Maven positions itself as more of a project management tool, and so the approach is somewhat different. In Ant we have the concept of “targets”, specific tasks that need to be defined in a build.xml file, and then executed by the tool. For example, using carefully crafted targets we can create WAR files, deploy them, perform various tricks, it’s all there. This approach is said to be “imperative” which my Latin studies immediately indicate to me that it’s very specific, and task-driven. Maven, on the other hand, takes a more “declarative” approach: there are certain things that need to be accomplished over the course of a project, so let’s set those out, and then do ’em. Subtly different, and aimed at a far larger group than us developers. Rather than focus on the specifics of assembling an application, Maven adopts a “Project Object Model” (POM) for its structure.

Let’s illustrate this with an example. You’re starting a new web application. You need to create the relevant project structure in your IDE of choice. You need to document it. You need to write test code, and then write your application code around that. You need to cut WAR files every now and again for interim builds (which need to be announced to an internal mailing list and website). Documentation needs to be updated. You need to work with your chosen source repository, be it Subversion, CVS, or whatever. You need to run all your tests, report on test / code coverage, report on progress in general, and so on and so forth. Enter Maven, with its concept of “goals”. Specify a bunch of goals, and let Maven do its thing: it automatically downloads and caches code plug-ins for each behaviour, reports on what it’s up to, and generally runs a tight ship.

I’m impressed.

Further reading

BTW, if you liked this post, you might also be interested in Spuggy’s one about AppFuse!

Comments

  1. Are you folks using CVS or Subversion?Jamie McIlroy#
  2. Ben, "What you talking about fool!".
    Source control, project build management never heard of them never seen em, dont bring em up here. Dont have any use for that posh southern stuff, I might have to get training.

    I wont need them to program my "Big Trak" anyway. Once I buy it from e-bay I'll finally have a slave.

    .. Its late I better go ..John Marshall#
  3. John — guffaw!

    Jamie — we have a dev box running CVS. I’ve played with Subversion too. But we're not supposed to use either. We're supposed to use some Rational thing (ClearCase / Quest? Can’t remember), but Rational costs, and no-one’s paying.Ben Poole#
  4. Thanks for the info. I'm just getting into WS Portal plus Site Developer. J2EE for a Domino/Notes developer is always scary but I finally found a place that wants to use it. So no more excuses.Eric T#

Comments on this post are now closed.

About

I’m a software architect / developer / general IT wrangler specialising in web, mobile web and middleware using things like node.js, Java, C#, PHP, HTML5 and more.

Best described as a simpleton, but kindly. You can read more here.

";