Matt RaibleMatt Raible is a Java Champion and Developer Advocate at Okta. developer.okta.com

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

RE: Why use Maven

Warner has a post about why he likes Maven. He might not know it, but he's actually ripping on AppFuse, its directory structure, and build file. I like getting ripped on, so that doesn't bother me. What bother's me is that Warner has comments turned off so no one can get him back. ;-)

The main reason that AppFuse uses Ant over Maven is speed. Maven runs much slower than Ant. Period. Also, with an open source project like AppFuse - I try to appeal to the larger audience, who likely has Ant installed. Other OS projects I work on (displaytag and struts-menu) both use Maven and people have a lot harder time trying to build from source b/c of Maven issues. Lastly, I like having a complete download - rather than download-dependencies-after-you-download-the-project like Maven does. I realize if I did use Maven I could package the dependencies in the app - which is likely what I'd do anyway since the main repositories seem to be constantly out-of-date.

Recently, I had a similar experience to Warner. As part of my current contract, I was tasked to write a couple of Maven sample apps. Warner came to my rescue and helped me out a lot, but I felt like I was jumping through a lot of hoops to do simple stuff that was already done in the Ant version of my app. I guess I'm just not a Maven guy. A project that's done right, regardless of if it's done with Ant or Maven, should build by typing "ant" or "maven" - or at least provide you help on what you need to type. Some projects, like Spring and Struts, actually allow you to use either one out-of-the-box. That's a pretty cool idea and likely keeps everyone happy.

It sounds like Warner has re-worked AppFuse to work with Maven. Care to donate your couple hours of work? I wouldn't use it personally, but there has been interest in a Maven version. Some folks seem to like slow build tools.

Posted in Java at Aug 04 2004, 03:29:04 PM MDT 26 Comments
Comments:

I don't know where did you get the idea that appfuse directory structure is yours. That's not the first time you bitch about it but i used to use a similar layout before ever hearing about appfuse. My base ant scripts and layout were based on the ant book and xpetstore which both date before your precious appfuse app. Between maven isn't slower than ant anymore. Have you used maven console?

Posted by 66.167.118.157 on August 04, 2004 at 05:35 PM MDT #

You are correct, the directory structure I found in Java Development with Ant, just like you. I didn't want to criticize anyone else though - so I took the blame myself.

Let's test the "Maven is as fast as Ant" theory. I have a couple of small projects with the same source source code - one Ant based and one Maven based. Here's the numbers for particular targets/goals to compare (I cleaned before running each one):

<ul class="glassList">
  • clean: Maven - 7 seconds, Ant - 2 seconds
  • compile: Maven - 11 seconds, Ant - 9 seconds
  • test: Maven - 40 seconds, Ant - 32 seconds
  • war: Maven - 47 (-Dmaven.test.skip=true yields 17 seconds), Ant - 9 seconds
  • Numbers don't lie. Granted it's not that significant, but I'll take any additional efficiency I can get out of this PowerBook. ;-)

    I've heard of Maven Console and also Ant Console. I haven't tried the Maven one, but the Ant one was buggy the last time I tried it.

    Posted by Matt Raible on August 04, 2004 at 06:02 PM MDT #

    Maven is actually much, much slower and cruddier than ant. I'd also say that anyone who thinks they can support ant just by having maven spit out a build.xml is in for a world of hurt. I've just modified the rome project (http://rome.dev.java.net) to work with a build.xml that is handcrafted, rather than generated automatically by maven. When you add in the subproject buildfiles, the total sun of build file sizes is actually much smaller for the ant files than the maven ones, thanks to ant 1.6. The ant task also, of course, downloads all external dependencies, and works with proxies and doesn't squirrel away the file in some random location that varies between users too. End result? The 3 people who use maven are happy, and the rest of the world can use ant and actually get up to speed on the project without too much pain.

    Posted by Hani Suleiman on August 04, 2004 at 06:08 PM MDT #

    Hey Matt, I would be glad to donate what I have done (when it's complete ;-). Sorry for ripping on you, but man it was extremely tough to figure out how everything was getting built and when it was getting built. After I posted this I realized that this might have been the original setup for appfuse. Maven Console makes builds much faster because Maven doesn't have to reparse the project.xml files and maven.xml files (if you have any). To start it just type maven console and then when it comes up type the goal you are attempting to do. I'd be interested in seeing what those numbers are. Here's a question though - Why do I have to jump through so many hoops to add in a new jar file? BTW - I haven't read Erik's book (He's a friend, although he may not be after my post ;-).

    Posted by Warner Onstine on August 04, 2004 at 07:06 PM MDT #

    Oh, and I turned off comments because I was getting spammed, but I left you the handy trackback ;-).

    Posted by Warner Onstine on August 04, 2004 at 07:07 PM MDT #

    Matt, why don't you patent this thing you call 'AppFuse directory structure'. :) Get the idea?

    Posted by Jason Barker on August 04, 2004 at 07:34 PM MDT #

    <em>> From Warner: Why do I have to jump through so many hoops to add in a new jar file?</em>

    It's not that hard - drop the JAR(s) into a directory in lib, add an entry to lib.properties and then add them to the appropriate classpath in properties.xml. I agree that it's more complicated than Maven, but this is the system I use. The nice thing is you can actually move the "lib" directory into a parent directory and use it for more than one project. On most projects, the packages I'm using are set w/in the first week, and then it's just a matter of dropping in new JARs and changing the version number in lib.properties.

    Posted by Matt Raible on August 04, 2004 at 08:36 PM MDT #

    I'm starting to see Maven as one of these things that people either love or hate. I'm not sure if that's a good sign or not.

    To each his own. Maven is in no way as fast as Ant. It's dog slow in comparison, but that really has no effect on my choice to use it heavily. It saves me a ton of work. Period.

    Maybe some people do like slow build tools, but I find your comment strange, nonetheless. To simplify the Maven/Ant comparison to "Ant is faster, so I'll use Ant" seems a bit numb to me.

    Ant 1.6 is awesome, with the macros and inheritance/inclusion system. I tried it out and was pleasantly surprised. But I don't want to write any build files anymore, unless I have to. I'd rather just let Maven do the work for me.

    Hani, it's true that Maven-generated Ant build files have problems. I tried it a few times, it kept putting absolute paths in there, so I stopped. Annoying. But your anti-Maven FUD continues to possess a very low signal-to-noise ratio. You just yell about how it sucks, but don't really say anything significant. But you are very funny, so at least your comments serve some purpose in that regard.

    Uh, a lot more than 3 people use Maven. Have you seen the mailing lists? Probably not. But a lot more people use Ant, definitely. But that alone doesn't make it better -- I think we all know this.

    Anyway -- I'm not a Maven groupie or anything, I just like it. If a better tool came along I'd use it.

    Posted by matth on August 04, 2004 at 09:21 PM MDT #

    I have to say that I've been using ANT for about three years and Maven for about 6 months and have to give the nod to Maven for the following reasons. 1) The docs and reports Maven can QUICKLY produce (some via xdoc) are fantastic, in fact they helped us recently a contract in an RFP process. BTW, managers love the documentation and reports! ;) 2) I'll take the performance hit if I gain something somewhere else (see one and 3). 3) Maven can do everything that ANT does and then some. 4) Uniform dir structure across projects. At first I didn't like Maven and thought it was too cumbersome and difficult but once I understoood the concepts I was well on my way to being a Maven fan. and didn't want to use for that reason, until I was 'forced' to by a colleague that had "seen the light" before me and "showed me the way". Warner, please let me know (and anyone else that's interested) when you've converted AppFuse to Maven. I want to use AppFuse (thanks Matt for a kick a$$ tool) for a few projects that I have lined up and would prefer :) to use Maven with it.

    Posted by Scott Williams on August 05, 2004 at 07:14 AM MDT #

    I agree with Scott that the documentation created by Maven is a big advantage of using Maven above Ant: coverage reports, JUnit results, code analysis results, they are all ready out-of-the-box, without having to rewrite the same targets for each project again.

    I agree that Maven is slow (very slow), but we tend to use Maven for the deployment process (creating a WAR file), whereas during development we use Tomcat & Eclipse. That way (using a shared classpath) we have instant code recompilation when developing. So there is no need for an external build tools like Maven or Ant during the development cycle; a separate machine with a cron-job makes sure the Maven deployment ("maven site") is done every hour or so. So in that sense a few seconds more or less are not that important.

    I'd love to see Maven and AppFuse coming together -- but of course, keeping 2 separate build mechanisms in place will require time and effort.

    Posted by Guus Bosman on August 05, 2004 at 08:28 AM MDT #

    The discussion so far has been about ant builds vs. maven builds, and I would agree that if it were strickly a build vs. build then ant is probably the way to go. It is simple and fast. However maven has its place in a bigger scope, namely in the documentation side. If you need project docmentation, then maven really rocks there. The reports and site builds are really, really nice, IF you need that kind of functionality. While doing that with ant is certainly possible, it is a bit more work.

    So, I would be of the opinion that if all you need is a build tool, then ant is the way to go. If you need a build tool, a site doc tool, then maven is probably the better solution.

    Having said that, I'm moving from maven to an ant/forrest solution for my chameleon project. I decided to use Forrest for documentation and I ended up using maven strickly for builds, which seemed overkill.

    Posted by Robert McIntosh on August 05, 2004 at 08:37 AM MDT #

    This subject definitely strikes a chord. My experience with Maven is very similar to Matt's. I really like the site generation, but I'm not too fond of the build aspects. What I would love to see is the maven project split out a build component and a site component where the build component can generate the artifacts for the site component to pick up, or you could use ant to generate those artifacts. From the comments, it seems I wouldn't be alone in this regard. I haven't looked into Forrest lately so perhaps I should take a look again. Gravy (Groovy + Ant) will rule soon anyway. :)

    Posted by Eric Weidner on August 05, 2004 at 10:48 AM MDT #

    Forrest isn't really geared towards project docs like Maven is. Maven has the nice report generation and stuff like that that forrest doesn't have out of the box. I believe the Centipede project is supposed to handle that (and is based on forrest), but there is little docs on centipede. I used Forrest because the good tab support and the website is geared to be more end user focused instead of project/developer focused (see: http://www.bull-enterprises.com/aom).

    I too am playing a little bit with Groovy (http://jroller.com/page/sftarch/20040802#dynamic_class_generation_groovy_vs) but I haven't looked at Groovy + Ant yet.

    Posted by Robert McIntosh on August 05, 2004 at 12:34 PM MDT #

    I'm one of those that loves maven. Why copy'n'paste ant scripts between projects? how many lines of xml do you need in ant to do what "maven jar" does? I agree that maven has problems and bugs, it has just released 1.0 not long ago, it's less mature than ant but is more active. e.g. the maven ant plugin has been released after maven 1.0, you have to update it if you want new features and bug fixes. Maven is better than ant in documentation and dependencies handling and it allows running ant scripts! If you want faster builds don't do "maven clean" and "maven jar"! just use "maven console" or "maven clean jar" Maven also imposes some good practises standarizing folders layout and the "one artifact per project" philosophy. If you don't like maven suggestions you can make ant scripts and run them from maven, but do it on your own. To sum up: with maven you can do everything you can do with ant and more, don't know any reason to use it, could you tell me one?

    Posted by Carlos Sanchez on August 11, 2004 at 05:15 AM MDT #

    I have two opinions about Maven and Ant. On one hand, if I am starting my own project, without AppFuse, I prefer to use Maven because writing a buildfile is a pain in the a$$. However, if I start off with an AppFuse project, I appreciate the speed of Ant and the fact that I didn't have to write the buildfile.

    Posted by Matt Moriarity on October 06, 2004 at 07:09 PM MDT #

    Maven is a pain in the a$$ full stop and it's slow. How hard is it to write an ANT build file ???? If it's too hard you should be writing javascript/php for a job not java.

    Posted by Bryan Hunt on November 10, 2004 at 08:44 AM MST #

    Re: "Why copy'n'paste ant scripts between projects?" Agreed why do it, why not just use the import task.
    Re: "Maven also imposes some good practises standarizing folders layout and the 'one artifact per project' philosophy." One man's best practice is another mans bleedin' straight jacket. Maven is a classic golden hammer, and for its advocates everything, quite mysteriously, begins to look like a nail.
    Re: "Maven is better than ant in documentation " Aha, at last the crux of the matter, maven makes pretty documentation; agreed, but its a bloody lousy build tool.
    Re: "If you don't like maven suggestions you can make ant scripts and run them from maven" Why not just run ant then and cut out the middle man.

    Posted by Mark Walker on November 30, 2004 at 09:21 AM MST #

    Just a quick thought.... One of the stronger benefits I see to Maven is the ability to generate a website for project administration, including the ability to report on CVS, jars, other reports, URL's for wiki's, bug tracking, and any other templates/site pages you want to create. I suppose the ability to package dependencies is also nice, but I will be the first to say that I have great lack in my understanding of both Ant and Maven. Thanks, Matt for the great ant script anyway. :)

    Posted by David Thompson on December 29, 2004 at 02:12 PM MST #

    Random thoughts from an admitedly Maven fan... <p/><p/> Re: "How hard is it to write an ANT build file ???? If it's too hard you should be writing javascript/php for a job not java." Well, I know that XML and Java are tightly related, and it's good that way, but Ant build files are still XML, not Java. When on a Java project, I like to code Java, not XML. Maven lets me concentrate on this. <p/> Re: "Aha, at last the crux of the matter, maven makes pretty documentation; agreed, but its a bloody lousy build tool." Sure, it does make pretty docs, as a side effect. One of the main reasons why I use it, though, is that it makes it easy for me to integrate unit tests in the build process, hence helping me write better code. It can be done with an Ant-only build, of course, but it's simply harder. <p/> Another good reason for me is the familiarity that I feel when building other "maven-enhanced" ;-) projects. Even if I didn't even know the name of the project five minutes ago, I'm pretty sure that I can type "maven jar", and I'll get a "target/project-version.jar". I wouldn't buy Maven for this only reason, but it's handy. <p/> Last, I'd like to say that for me, USING Ant or Maven is equal. WRITING Ant build files is what I don't like. As long as Ant's targets aren't dumbly named, it makes no difference to me to type "ant compile", "ant test", "ant deploy-webapp", etc. <p/> I don't care if a project has a "build.xml", a "project.xml", AND a ".project"... Use whatever tool is best FOR YOU. <p/> BTW, it IS slower than Ant. Well, if speed ruled my life, I'd go for C.

    Posted by Stéphane Mor on February 10, 2005 at 11:05 PM MST #

    I am new to Maven and had been using ANT quite often. From the previous messages it looks like ANT build.xml can be used with maven. Lets say I decide to build with ANT and generate reports with maven. Is this really possible?

    Posted by Naval Sarda on August 18, 2006 at 10:49 PM MDT #

    Naval - you can use Maven and Ant in the same project, but you will need to have both a build.xml and a pom.xml. For an example, see Equinox.

    Posted by Matt Raible on August 22, 2006 at 11:54 AM MDT #

    Just playing around with AppFuse 2.0, cool job. What led to the change of heart over Maven?

    Posted by Chui on February 26, 2009 at 04:49 PM MST #

    I don't know how complex is AppFuse, but in very large projects you need to have some discipline over the build system. There maven can help a lot, even if it is slower. I have written more details here: http://cristivulpe.blogspot.com/2009/07/why-should-we-use-maven.html

    Posted by cristi on July 06, 2009 at 11:50 PM MDT #

    Starting from a certain practical perspective, I wish that either Maven 2 or Ant was easier to get started with, for automating operations using the Forrest tools - that being to the nature of my usage case. I'm familiar with Make and a certain Common Lisp build tool, one ASDF. Starting with that background, then just as honestly, and in my opinion: Ant looks like a hack for hacking the build process, and Maven like a hack for hacking dependency integration, build, and deployment. Not to burst anyone's bubble, but outside of the body politick about these things, none of it looks all too fancy, as I honestly see it. I could really prefer to use Make, at this point -- at least it's consistently and completely documented, in a practically useful way, for the syntax of Makefiles - namely, in the single body of TeXinfo documentation about GNU make. As far as big projects using Make, then, I don't choose to ignore the precedents set of the Linux kernel project. I'm aware that that's a project in the C domain, but have we not all learned about Turing completeness and what? Is it that tough to write more of concretely useful documentation about ant? I don't find all the opinions about it to be so useful, after all, and I'm afraid that I do not believe I can learn about it by osmosis. Comparatively, it seems to me that Maven is more comprehensively documented - even in so much as the single book, available online, Better Builds With Maven. I will use Maven, then. However long it will take to determine, concretely, how Maven 2 would be used to automate the publishing of a web site, using Maven 2 to drive Forrest (by way of ant, as I guess it'll have to be, at least to start with) but - for all its quirks - I honestly believe that Maven 2 is the more thoughtfully designed tool. Not to start a flame war, just taking it kind of seriously. Cheers, then, folks.

    Posted by Sean Champ on August 24, 2009 at 03:08 AM MDT #

    Starting from a certain practical perspective, I wish that either Maven 2 or Ant was easier to get started with, for automating operations using the Forrest tools - that being to the nature of my usage case. I'm familiar with Make and a certain Common Lisp build tool, one ASDF. Starting with that background, then just as honestly, and in my opinion: Ant looks like a hack for hacking the build process, and Maven like a hack for hacking dependency integration, build, and deployment. Not to burst anyone's bubble, but outside of the body politick about these things, none of it looks all too fancy, as I honestly see it.

    I could really prefer to use Make, at this point -- at least it's consistently and completely documented, in a practically useful way, for the syntax of Makefiles - namely, in the single body of TeXinfo documentation about GNU make. As far as big projects using Make, then, I don't choose to ignore the precedents set of the Linux kernel project. I'm aware that that's a project in the C domain, but have we not all learned about Turing completeness and what?

    Is it that tough to write more of concretely useful documentation about ant? I don't find all the opinions about it to be so useful, after all, and I'm afraid that I do not believe I can learn about it by osmosis. Comparatively, it seems to me that Maven is more comprehensively documented - even in so much as the single book, available online, Better Builds With Maven.

    I will use Maven, then. However long it will take to determine, concretely, how Maven 2 would be used to automate the publishing of a web site, using Maven 2 to drive Forrest (by way of ant, as I guess it'll have to be, at least to start with) but - for all its quirks - I honestly believe that Maven 2 is the more thoughtfully designed tool.

    Not to start a flame war, just taking it kind of seriously, over limited time. Cheers, then, folks.

    Posted by Sean Champ on August 24, 2009 at 03:09 AM MDT #

    Hey, folks, sorry about the double-post - the web-app driving this blog appears to have been experiencing some hiccups, at the time I was writing the comment. So, with the error pages and "comment authentication failed" messages that were coming up, I hadn't stopped to check if the comment had actually been posted - which, as I see now, it had been, twice over. Inasmuch as I have anything to apologize about, sorry about that ^-^ Good evening, then, and thanks for all the fish....

    Posted by Sean Champ on August 24, 2009 at 03:13 AM MDT #

    Post a Comment:
    • HTML Syntax: Allowed