Wednesday, December 6, 2006

Maven 2: Snare and Pitfalls

Last Saturday I presented Maven 2 at JaMU 24.
The world of Maven is still growing, expanding, and there are lots of unexplored area. Newcomers could be discouraged to use Maven 2 because of certain things which could make them stuck.

Here are some of the snare and pitfall while setting up Maven 2:

1) Creating the "~/.m2" folder in Windows environment

The "~" (tilde) is a common representation of user folder in the UNIX/Linux systems. In Windows, it usually maps to "C:\Documents and Settings\your.username", "C:\Documents and Settings\your.username.DOMAIN", or "C:\Documents and Settings\your.username.DOMAIN.001", etc.
When we try to create a folder in the Window Explorer using the File - New Folder menu, Windows will display a stupid dialog telling you "you must type a filename". Obviously we want to create a folder, so the message should be "you must type a folder name".

After struggling for a while I eventually managed to create the folder using Cygwin's bash shell. Of course this is not solving the problem when you don't have Cygwin installed. And Cygwin brings POSIX personality to NT platform. I believe there are some other way to create such files, like calling the Windows API to create the folder. But I eventually found the simplest thing to create the folder, unzip a folder with that name using your favorite zip tools!
I included the file in the starter kits (uploaded to JUG-ID file repository).


2) Got the message "generics are not supported in -source 1.3"

What has happened right here?! You are sure of using JDK 5 already, but yet you still got this message.
The problem is that the default setting for maven-compiler-plugin is to use the JDK 1.3. So the workaround is to add this to your pom.xml file in the section:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin&g;


3) Setting up the right environment variables to run the Maven 2

No comments:

Post a Comment