tags:

views:

305

answers:

8

I am newbie with maven.

Other than its use for managing dependencies, I am finding little use for it.

It was getting so hard to write up a pom.xml, that I generated a ant build.xml from one of maven's tasks (which is a nice handy task...) I had to tweak the build.xml that was generated by maven. And now all my compiling, testing, etc., is being done with this build.xml..

Is such a combination common? I am thinking of making it permanent in my project.

+2  A: 

So you re-did what Maven gives you for free by writing Ant Tasks within a pom.xml?

Besides doing the Dep-Mgmt, Maven will compile the sources, run all test cases and package the whole thing as jar file for you with no extra configuration. That's the default.

It is not common to enrich a pom.xml with Ant clutter. However, some special tasks or legacy Ant tasks are sometimes embedded into the pom.xml lifecycle, but these are exceptions and not the common case.

What exactly is hard when writing a pom.xml?

I wonder, because most of the time you will do this once for a project and not struggle with it all the time. Also, most IDEs have support for creating the minimum pom.xml, which is just a few lines anyway.

mhaller
maven generated a separate build.xml for me. So the ant tasks weren't "in" the pom.xml. The build.xml that was generated by maven, had to be tweaked to fit my needs.The hard part for writing the pom.xml, was the learning curve.. I have one 'parent' ant file.. and the 'child' ant files: one for regular tasks, one for testing, one for some functional tests, one for 3rd party library checks.Its gonna be hard to write a pom.xml to do all those things. that 'artifact' task is really not that big a time saver if you know ant, and have some samples ready to use.
rjk2008
Maven does not generate any build.xml. There is not "artifact" task in maven. I wonder if we're talking about the same software 8)
mhaller
Maven does generate an ant build.xmlhttp://maven.apache.org/plugins/maven-ant-plugin/usage.htmlI shouldn't have used the words "artifact task". What I meant was the Archetype. Here's the one I used:http://maven.apache.org/plugins/maven-archetype-plugin/examples/webapp.html
rjk2008
Didn't know about maven-ant-plugin. however, why did you use that in the first place? Try to do stuff first in Maven, without touching Ant. Then you will learn and see why it's better for enterprise applications.
mhaller
+3  A: 

I've tried Maven, personally for home projects and professionally at my workplace, and... I hate it. I must admit I don't have a lot of experience, but it doesn't feel good. I get the idea Maven is a less-than-perfect implementation of a good idea. I'll probably get flamed by Maven enthusiasts, but this is my personal opinion.

I think Maven comes into its own in organizations that deal with a network of interrelated projects, like Apache does; where dependencies tend to change a lot and need to be quite explicitly specified to avoid "jar version hell". For isolated projects dependent on a few seldom changing jars, I find it overly intrusive.

To answer your question: I've read forum and blog posts on the Internet of other people doing exactly what you propagate. They use Maven for dependency management and then do their building with Ant. This undermines some of the benefits Maven is supposed to bring, such as the fact that a "normal" build is simpler to specify in Maven than Ant. However, I think you can be encouraged by the fact that you're not the only person with this idea, and it is indeed working for some other people.

I'd like to give you links to quotes, but I came across this stuff in the past few weeks and didn't collect references.

Carl Smotricz
You're right, Maven **is** heavyweight and less than perfect, esp. the IDE tooling. However, it solves some of the problems you have when maintaining commercial software in a large enough and distributed team. I wouldnot use Maven for a personal project which consists of 10 classes and only uses 2 jar files.
mhaller
This might be one of the links you are referring to: http://tapestryjava.blogspot.com/2009/10/maven-throwing-out-bath-water-keeping.html. And this was one of the responses to that article: http://www.sonatype.com/people/2009/11/maven-howard-how-to-execute-the-perfect-oss-drive-by-shooting/
Dan Dyer
I love answers like "I don't know it but I hate it". Let me rephrase it: I don't know what I'm talking about but I'll give you my opinion anyway. And this gets upvoted... yeah!
Pascal Thivent
@mahler And why wouldn't you use it for 10 classes and 2 jar files? A minimal POM allows you to compile, run tests, package, install... and can be generated in one command. Adding 2 dependencies won't cost you more that 1mn. So really, I don't get your point.
Pascal Thivent
IBM has worked very hard to make the Visual Age (remember Visual Age?) / Eclipse experience the best it can be. Hit Ctrl-S, you save and compile *immediately*. Maven manages to thoroughly destroy this feeling by inserting several seconds of thrashing around and a stream of meaningless messages. This alone is sufficient reason for me to want to print out the Maven source code and then burn the printout.
Carl Smotricz
Dan Dyer, I saw the post you mentioned but that's not one of those I was referring to. I didn't find myself agreeing with Howard Lewis Ship either; his solution looks much worse than the cure. I'm off to go read Sonatype's rebuttal, out of curiosity.
Carl Smotricz
Err, cure much worse than the disease. I'm sure you understood what I meant.
Carl Smotricz
@Carl What are you talking about? Coding in a IDE is one thing (and yes, I used Visual Age), building outside an IDE is **another** one. So don't expect the same intent, this doesn't make any sense. How would you do continuous integration with Eclipse? You can't. Does that make Eclipse useless? No. Really, I don't see what you want to prove.
Pascal Thivent
Well, the Eclipse experience extends into, say, the Web app container. Ctrl-S and you're ready to refresh and look at a page in the integrated browser, running the new code. Can you do that with Maven? Oh no, the first thing you do is fire up a new Jetty server. Minutes later...
Carl Smotricz
@Carl Did you read what I wrote? Eclipse and Maven **do not** have the same intent (and one doesn't exclude the other) so what's the point of comparing them? By the way, don't you have to start a container too with Eclipse? End of the "discussion" for me, I don't want to argue more, it's just useless.
Pascal Thivent
I don't agree about the visual age comparison either. If you are using linux (sym link the webapp folder) .. you don't even have to copy-paste anything.. just reload.That said the time taken by maven to 'compile' my 5-6 classes webapp .. is really a lot!!. but there might be way to reduce that time which I dont know of yet
rjk2008
I'll shut up now. Thank you for your thoughtful comments! We are lucky to be living in a world where you can do Maven and I can do without and all of us can live happily ever after anyway.
Carl Smotricz
A: 

If you just need dependency management with Ant, you could give Ivy a try. Maven is a tool for managing the whole lifecycle of the build process.

Personally, I find Maven a nice tool once you get over the learning curve since you can standardize the build process for a lot of projects and there are a lot of great add-ons (particularly for code analysis tools). However, it's very possible that you do enough custom stuff with your build that the Ivy + Ant combo makes more sense.

Jason Gritman
I would rather use the maven tool for dependency mgmt, mainly because almost all applications/libraries seem to ship with their own pom.xml's.
rjk2008
If you use the Spring Source Bundle repository (http://www.springsource.com/repository/app/) you can find ivy configurations for most of the common 3rd party libraries.
Jason Gritman
+1  A: 

I'm a Maven fan, but it's not without its problems. Some of the issues I remember (and still fight):

  • Just like Ant, it has a magical syntax that can be hard to understand. If you're familiar with Any you may forget that, but lots of Ant tasks are terribly documented. The same is true for Maven. One of the reasons I eventually switched to Maven, though, is that for many of the mojos (similar to Ant tasks), you don't have to understand how to configure them. You just have to put the various pieces in the right place (which can be as hard as configuring a task...).
  • The automatic dependency management is amazing!... when it works. When you have to use non-Maven dependencies (like Hadoop) it becomes a problem. You either have to reference them as system scope dependencies, find somebody else who has packaged them, or package them yourself. And you eventually need to setup your own Maven proxy, like Nexus. And that's a whole extra hassle.
  • Maven is a lot of trouble on non-network or isolated LANs. The automagic is great, as long as you're networked.
jonathan-stafford
+7  A: 

Other than its use for managing dependencies, I am finding little use for it.

That's because you don't get it :) Dependencies management is only a small part of Maven, Maven has really much more. Quoting Maven: The Definitive Guide:

Maven is a project management tool which encompasses a project object model, a set of standards, a project lifecycle, a dependency management system, and logic for executing plugin goals at defined phases in a lifecycle. When you use Maven, you describe your project using a well-defined project object model, Maven can then apply cross-cutting logic from a set of shared (or custom) plugins.

Maven uses convention over configuration with lots of useful defaults (directory locations, a defined life-cycle, a set of common plugins that know how to build and assemble software), Maven provides a common interface to build project (unlike Ant, you know how to do things like running tests, packaging, etc with every project, no need to open the build script to find out how it's done), Maven implements reuse through maven plugins (build logic is embedded into plugins for DRY purpose, you don't have to repeat yourself over and over, you don't have to copy/paste parts of your build scripts), Maven has a Project Object Model that allows you to describe your project through meta-data (this enables dependency management, remote repositories, reuse of build logic, tool integration, artifacts search...).

So, because Maven provides a lingua franca or shared language for project management, comparing Maven vs. Ant (+ Ivy if you want), Maven vs. Buildr, Maven vs. Gradle is like comparing apples to oranges, the comparison is just irrelevant.

Is such a combination common? I am thinking of making it permanent in my project.

Well, no, that's really not the maven way of doing things. This might seem tempting (because you have the feeling that you regain control because you understand what is happening with Ant) but you are actually repeating yourself again and loosing all advantages of Maven. Sure, there is some learning curve with Maven and I'm not saying you'll learn it in one night but once you'll get it, you'll feel the power. I'd thus recommend to keep trying, to ask questions on the mailing list or here on SO, to read the Maven Book, etc. But don't give up.

Pascal Thivent
I think you make some really good points. A part of me wants to jump in and go with Maven all the way.. but I have a really bad feeling, that most projects do end up having a maven+ant combo. Even for the 'procedural' part. And I don't want that to happen to me. I would rather just give ALL the procedural duties to ant, and let maven only deal with dependencies.
rjk2008
To my knowledge, most projects do not end up using Maven+Ant, this is a misconception. Some projects may use the maven-antrun-plugin to run ant tasks from Maven for very unusual needs but I wouldn't even call that a maven+ant combo. To be honest, I think that you're underestimating the power of Maven. Do you have any example of things you can't achieve with Maven?
Pascal Thivent
Wish I did know of those. decision would've been easier. One thing I was going to ask was: "wsdl2java" but... apparently maven supports a plugin for it, and source files get auto-magically generated during some generate-src stage. A lot of my concern was for the EAR file generation and the static content that needs to go in specific locations.. but I think if I create my 'resources' dir correctly, I could get by. I *might* have sub-projects i.e. applets, clients-jars that do RPC. I prefer to generate (if needed) such things whenever the EAR is built.
rjk2008
Maven can do lots of (and very complex) things and the samples you gave don't seem to be extra weird use cases. The comment system is maybe not the ideal place to discuss them though :)
Pascal Thivent
+1  A: 

It was getting so hard to write up a pom.xml, that I generated a ant build.xml from one of maven's tasks (which is a nice handy task...) I had to tweak the build.xml that was generated by maven. And now all my compiling, testing, etc., is being done with this build.xml..

Well. you can use maven archetype plugin to generate pom :)

Is such a combination common? I am thinking of making it permanent in my project.

JBoss Seam uses Maven internally to handle dependencies and do some targets in Maven. It's a big project that grew up with Ant, and now is difficult to build entire project solely in Maven, but that is going to happen in near future.

cetnar
A: 

Honestly, I would love to see a dependency management tool that implemented that part of Maven, specifically as a command line tool. For everything BUT dependency management, I find Maven to be absolutely awful if you're doing anything but exactly what the most general case is. Every time I try to do something that isn't "normal" (system/acceptance tests, etc), I run into a brick wall due to

  • either horrid documentation,
  • being told it's "not the maven way" (when it's a task that needs to happen, and "the way" shouldn't be a factor), or
  • being told to wait for the next version of maven, because maybe it'll be supported then.

I'd love to have a command line tool that can implement the "I need this as a dependency, go get it" functionality of Maven, possibly even using the pom.xml files of various packages. Then I could just use that in a Makefile and happy :)

RHSeeger
A: 

Simple answer to the question posed: YES <-- click the link for details and reasoning.

Peter Thomas