I'm currently wrestling with Maven and I have several gripes.
I'm using version 1.0.2. Before complaining that I should upgrade: the 1.0.2 version is considered stable, so is considered by the Maven team as suitable for a production environment.
On to my gripes:
- Maven tries to set one standard directory structure. This goal is gradually reached with each version, which I can understand. However, why the hell isn't this made clear? Different directory structures are all over the place:
- The structure you generate with maven appgen is different from what is documented on the website.
- The website itself is inconsistent. Then ten-minute-test for Maven 1.0 specifies src/main/java and other random pages (this one for example) specify src/java
- You're building a war, so you use the ten-minute-test directory structure. It all works, except your index.html and web.xml don't get included in the resulting jar. After an hour or two, you find the maven.war.src setting for your project.properties and you set it to ${basedir}/src/main/webapp
- It's possible to do maven eclipse and generate a faulty .project and .classpath
- Sometimes, <resource> sections don't get included when doing a maven eclipse (see below)
- Why isn't documentation delivered along with the download? Now you don't know whether the website reflects 1.0.2, 1.1beta or 2.0 alpha.
- If you're behind a proxy, you have to set that proxy in your project.properties otherwise maven can't reach ibiblio.org -- however, if you do a maven site:deploy, you have to switch it off again because you're deploying to an internal box; it doesn't know that this particular box is internal (this is more of a Java problem in that it doesn't have a good integration with how the underlying OS administrates proxies).
Be careful with multiproject, too:
- Do you actually need it? Is it necessary that SubProject A and SubProject B use different versions of SharedSubProject C?
- Say you increment the version of a subproject and you increment the version in the multiproject.xml. Build. Watch it fail. You should first build the subproject manually!
- How are you going to manage those versions in CVS? Set up procedures for this. Maven does not magically help you with proper tagging and release procedures.
- Multiproject and xdocs don't work intuitively; for instance the javadoc from the subprojects is not reachable from the main page when you provided your own navigation.xml
- You can't do maven multiproject:eclipse or maven multiproject:idea
- If I have a multiproject, why can't it figure out that the subprojects depend on each other? It's already specified in the project.properties of the main project. Yes, a colleague found out you can do pom.currentVersion, but Maven should be able to figure this out automatically.
<dependency>
<groupId>UberProject</groupId>
<artifactId>UPNet</artifactId>
<type>jar</type>
<version>${pom.currentVersion}</version>
<properties/>
</dependency>
- The same basically goes for multiproject and the eclipse goal: subprojects are included in the classpath as jars, but typically you work on both so you'll have to manually delete the jars from the classpath and add the projects
- More of a gripe with Eclipse: multiprojects and Eclipse don't really match.
Conclusion
I've got most of it figured out, but I've wasted so much time that I could've written three complete Ant scripts by hand. So, it takes around three projects to get an increase in productivity by using Maven. In conclusion, I would advise other developers to stick with Ant and wait for this mess to be cleared up.
Plugin problem
Oh and if you have to upgrade a plugin because it has a bug, take the following steps to avoid this message:
WARNING: Plugin 'maven-site-plugin' is already loaded from
maven-site-plugin-1.6.1; attempting to load maven-site-plugin-1.5.2
- Remove the cache directory in ~/.maven
- Copy the jar of the new plugin in your Maven its plugin directory
- Remove (DON'T JUST RENAME) the old version of the plugin
We had to upgrade maven-site-plugin from 1.5.4 to 1.6.1 and I renamed the 1.5.4 jar to maven-site-plugin-1.5.4.jar.bak -- however by some crazy mechanism Maven downloads the old plugin into your cache again.
Eclipse filter and empty directories
There's a problem with Eclipse which isn't likely to show up except when you use CVS and Maven its Eclipse plugin.
Suppose you have a bunch of empty directories and when you check out with Eclipse, you filter them:
- Going to the Package Navigator and pull open the menu
- Select Filters
- Choose "empty packages"
Also, you have a directory structure like this:
myproject
\--- src
|--- main
| |--- java
| \--- resources
\--- test
|--- java
\--- resources
You run maven eclipse to generate your classpath, which will now include main/java and main/resources. In main/resources, a bunch of properties files reside. You want to be able to see them. But you can't. Why not? Eclipse decided it's an empty package. Which it is....
What's conceptually wrong here is that Eclipse doesn't have a classpath setting, only a source path setting (configurable via menu Project, Properties, category Java Build Path, first tab Source). But it's not a source path, it's part of the classpath!