Saturday, August 12, 2006

Does Maven actually make things easier?

I've been using Maven 2.0.4 for the last month or two and am discovering that I spend so much time dealing with Maven that I am wondering if I should give it up completely and go back to Ant.

I used Maven archetypes to set up my project modules, and that worked pretty well. But almost immediately, I found myself on the Maven treadmill.

One of the improvements that Maven 2 has over Maven 1 (which I have never used) is support for transitive dependencies. That means that Maven will download not only the artifacts (usually jars) that your project needs, but also any artifacts that those artifacts need, and so forth, to any depth. It sounds cool, but it's not so simple in practice.

For one thing, in order to figure out the transitive dependencies, Maven has to download the POM (project object model) files for all the dependencies, but many artifacts in the Maven 2 repository do not have POM files. In that case, I have to work out the dependencies myself and add them to my project's own POM file. Meanwhile, Maven will try to download the missing POM files every time I build the project and raise the same warnings over and over again.

Even when an artifact has a POM file, it sometimes causes more problems than it solves by referencing artifacts that you don't actually want in your project. One such case is when artifacts reference different, incompatible Spring Framework components; for example, one artifact may reference spring-core-1.2.7 while another references spring-web-2.0-rc3. And sometimes you just don't want the artifacts in your project because you know that you're not going to use them; as an example of this, Spring WebFlow pulls in Struts, even though I'm not developing a Struts application. Another annoying example is the tendency of applications to pull in Log4J, which, when present in the classpath, causes the behavior of Commons Logging to change. Maven allows me to correct all these problems in the POM file--I can force Maven to use version 2.0-rc3 of the Spring components, and exclude Struts and Log4J--but I have to add a lot of extra lines to my project's POM file.

So far I've focused on missing and/or inappropriate POM files, but sometimes it's the artifact itself that's missing from the repository. Specifcially, none of the Sun jars are in the repository, due to restrictions imposed by Sun. I was also unable to find the Cache Taglib from the Apache Taglibs project. In each of these cases, I must download the jar myself and manually add it to the local repository. And if another person works on my project, then that person must also download the jars.

So I'm spending time downloading and installing jars and sorting out dependencies. Tell me again what Maven is doing for me?

Oh yes, all those plug-ins, like the automatic project web site builder, and the IDEA project generator. Those features are nice, but they are hobbled by a lack of good documentation. The documentation for the IDEA project generator plug-in, for example, doesn't make any mention of the available options; I found out about the options from a discussion board. And configuring the plug-ins requires a excessive amount of XML. I had to write all this just to use Java 5:


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-idea-plugin</artifactId>
<configuration>
<jdkName>1.5</jdkName>
</configuration>
</plugin>
</plugins>
</build>


What I really want Maven to do, more than anything else, is manage the dependencies and build the project. The fact that I have to spend a lot of time doing those things myself is what makes me wonder if maybe Maven is one of those tools that solves 80% of some problem but then makes the other 20% a lot harder.

0 Comments:

Post a Comment

<< Home