Tuesday, April 27, 2010

Maven Configuration Setup

As I was doing the Hibernate tutorial (which is a nightmare by the way), I was required to learn about Maven and the HSQLDB database server. To build the tutorial, you have to use Maven and HSQLDB. Following this tutorial step by step was impossible, and in Hibernate's community forum, it seemed that I was not the only person complaining.
HSQLDB is pretty straightforward to set up. It is a full Java database; its database server runs with the java command from command line and it also comes along with a Swing client.
Maven is a little more challenging. Maven as far as I understand is similar to Ant but is easier to manipulate. Like Ant, it's a build automation tool and a project management tool.

Once, you have downloaded Maven installation file, follow the configuration steps in the readme file. Yes... it seems obvious but I rarely read readme files. Maven website doesn't give directions for basic configuration. So when I started Maven's tutorial, nothing worked. I was stucked with Maven, and I could not go ahead with Hibernate. Here are the basic directions from Windows or Linux:
- Unzip the files in a folder.
- Add M2_HOME environment variable (user level).
- For Linux, add a M2 environment variable that points to $M2_HOME/bin at user level.
- Optionally, add MAVEN_OPTS environment variable with the following values: "-Xms256m -Xmx512m".
- Make sure the JAVA_HOME is defined.
- Add MAVEN's binary files into PATH (M2_HOME\bin for Windows and M2 for Linux).
Test your configuration from the command line interface with: mvn --version.

No comments: