dimanche, janvier 28, 2007

Maven Goodness!

My "customized" definition of maven:
Maven is a tool which helps creating, building and managing Java projects
It is based on the fact that software developers seem to do the same set of actions on each and every project they work on:
-Creating the project filesystem, which can be simple for CLI or swing based applications, but less evident for web applications, where anything decided will impact the ANT script
-Creating the associated build.xml file if they are using ANT
-Setting the appropriate classpath by downloading and importing the relevant libraries
-Praying that those librairies will work with their application
-Packaging and deploying, which implies the availability of an application server
-Testing
-To rely entirely on the IDE, to carry out all the project related actions, which obviously implies the availability of the IDE
-If someone joined the project, the whole setup of the developers will be duplicated and configured again, which is again a waste of time
-Generating project reports
-Making your project available to the outside world

Enter Maven, which I admit I resisted using, because of the "apparent" steep learning curve and the fact that it had big similarities with ANT.

What are Maven selling points ?
-Regarding to project filesystems, Maven defines the concept of an application archetype, which among many things specfies the layout for the project, but doesn't impose it on the developers, but for starters, this is a big thing, as it makes all the other features of Maven work almost out of the box
-There is no build.xml file to maintain, at least not in ANT fashion, Maven uses a POM file, which is automatically generated when the application is created
-Actually the most important thing you'll have to do will be to define dependencies and their versions, which is specified declaratively in the POM, by doing this many things will happen behind the scenes during the first build
The automatic download of dependencies (a concept called transitive dependencies), so if your application is Spring 1.0.1 based, Maven will automatically download Spring version 1.0.1 with all the required dependencies, before, you had to either include all the dependencies, or try them one by one to see if the compiler complains or rely on experience ;), those days are over. Since Maven is more and more poopular, nearly all the opensource projects, and even the commercial ones, update the popular Maben repositories with their libraries, and even if they are not available, you can install them to your private repository with ease
-For the deployment features, the best example I have was the case of a spring based web application, where I only had access to Maven, and an Internet connection, nothing else ;), I created a web application archetype, then I specified a dependency on Spring 1.0.1, I simply typed "mvn jetty:run" on the command line, and watched the magic operate: the automatic download of everything I needed, plus the Jetty download, the initialisation of the servlet container, and the deployment of the application, all I had to do after that was to connect to my application via a browser. It was then that I converted to Maven ;)
-For the testing aspect, when an archetype is run, Maven automatically downloads the required testing libraries, and creates the relevant test package, even with a stub class, and I believe that when the infrastructure of testing is already there, even before starting to code your application, you are much more inclined to to test driven development. There it is, a simple idea, with huge effects
-Maven has plugins to the major IDE vendors, the eclipse plugin shows this in a powerful and easy way
-There are many opensource projects which provide Maven plugins to generate all sorts of reports, which need only to be called declaratively in the POM, again, Maven takes care of everything, It downloads and configures the plugin and its dependencies.
-With Maven you can generate easily a site which can be deployed in one step to any webserver, without writing any code

Conclusion:
convert as soon as you can! and remember, all you need is:
-A JDK
-An Internet connection
-And Maven ;)

Aucun commentaire: