Monday, February 20, 2012

Why I hate Maven

Yes, I admin that Maven has improved the development of Java programmers because the tons of dependencies each project brings.

So why I hate it so much? Well, because the thousands (really thousands!) of network calls to the remote server to:

  • check versions
  • check md5
  • download pom.xml files
  • download jars

But why Maven has been realized in the way we know? All the logic is at client side. This means that each Maven user pays the absurd latency cost for each network calls! The solution? Git teaches.

Why don't build a tree of requested JARs, send it to the Maven server and download the resulting zipped archive containing all the stuff to install in one shot?

In this way updates daily updates would take ms or just some seconds depending by the updates and the network bandwidth, not any more by the network latency.

7 comments:

seralf said...

i think the problem it's also related to the "philosophy" they had implemented: as far as i know you should setup some kind of internal server (nexus + jenkins, etc) which take care of the update process to the several repositories, then you do the downloads from your local server.
The cons are in the cost of another server :-) and in an approach not so much decentralized as git/mercurial that you suggests :-/

i look forward to any alternative you could find :-)

Colin Hebert said...

First for the poms, you can't build a dependency tree to download pom files (as the dependencies are defined in these files!), so you have to download every pom, one by one.

Once you've got your pom files, you have to build a tree (easy) and then download dependencies which can be on different servers/repositories. To do so you can either ask to every repository to zip and upload to you tons of jar files (that's not really effective), or try the first server then the second.
The second solution isn't really effective as you can't have parallel downloads, but for the sake of this argument let's try this anyway.

You then download a HUGE zip file containing everything, if you're lucky, you're the only one asking for this or the server you're asking to do this is really resilient (it needs to compress every jar files for your project so it can be really heavy). But you still need to be lucky for your operation to succeed (if the gigantic zip file gets corrupted all that work is done for nothing).

So no, this is not a good idea.

An idea I was working on (one year ago) was to have the repository doing the resolution part itself, so you don't have to download every metadata/dependency file (here pom files). But in the end it costs so much to do this kind of operation for every request [actually not that much if you're smart and just flatten the metadata files (except for "snapshots") so you know the entire dependency tree] that it's better to just let every client to that on their own.

"The solution git teaches"... Really ?

git downloads the ENTIRE repository the first time you get the content. How is that even remotely a good solution to download every dependency in the world?

Mathew Bukowicz said...

I also don't like Maven, because it makes simple tasks troublesome. For example creating an executable jar with dependencies or building next version of an application should be piece of cake, but aren't.

As for the inconvenience of downloading the whole Internet, you should go for a coffee the first time you execute Maven :). The other times argument -o (offline) is preferred, like:
mvn -o clean install

Alan said...

I think you're oversimplifying the problem that Maven is trying to solve.

Yes, it's true that Maven can be horribly slow sometimes, and it's even true that you may wait forever if you don't setup a caching repository manager in your intranet.

But you should remember you're really re-downloading things for SNAPSHOT dependencies only - otherwise the local repo on your hard drive will just do!

And if you don't want to, the offline mode is at your service.

What would you replace Maven with? I sometimes long for it when developing in other environments (esp. Python and Ruby) that don't offer such advanced facilities.

Luca Garulli said...

@Colin The solution in my mind is to send to a Maven server:
- the list of JAR I need for a project
- the complete list of jars + versions I already have on my local m2 directory

With these information the server could prepare a zip for me containing all I need. 1 network call.

Luigi Viggiano said...

I don't care at all of the network traffic that maven does.

What I hate in maven is the lack of documentation, the absurd command line, the lack of a decent help system (man for example) for the goals, plugins etc.

How do you create a new project in maven? Here:

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

And that command is taken from the most basic tutorial.
What is maven? (http://maven.apache.org/what-is-maven.html) wrong! maven is gym for the fingers :-)

Luca Garulli said...

Seems that in the Java space it's pretty common to write complicated things. The Java history is full of it: J2EE, Entity Beans, tons of patterns about layers (DTO+DAO), etc.