You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by co...@apache.org on 2010/03/17 21:51:00 UTC

[CONF] Apache Lucene Mahout > BuildingMahout

Space: Apache Lucene Mahout (http://cwiki.apache.org/confluence/display/MAHOUT)
Page: BuildingMahout (http://cwiki.apache.org/confluence/display/MAHOUT/BuildingMahout)

Change Comment:
---------------------------------------------------------------------
Added Drew's Eclipse/Maven import suggestions

Edited by Jeff Eastman:
---------------------------------------------------------------------
h1. Prerequisites for Building Mahout

* Java JDK *1.6*
* Maven *2.0.9* or higher (http://maven.apache.org/)

h1. Get the Source Code

h2. Latest (Recommended)

Use [Subversion|http://subversion.tigris.org] to check out the code:
{code}
svn co http://svn.apache.org/repos/asf/lucene/mahout/trunk
{code} 

h2. Release

[Download source | http://www.apache.org/dyn/closer.cgi/lucene/mahout/]
Maven artifacts should be in the usual place: http://repo2.maven.org/maven2/org/apache/mahout/ 

h1. Compiling

* change directory to the checked out directory
* mvn install 

{note:title=Important}

If you are Compiling under Windows, make sure you installed Cygwin correctly. Here is a [good tutorial|http://hayesdavis.net/2008/06/14/running-hadoop-on-windows/] on installing and configuring a Hadoop cluster on Windows, and it points out at antoher great tutorial about installing Cygwin. Here is another [good tutorial |http://ebiquity.umbc.edu/Tutorials/Hadoop/00%20-%20Intro.html] for setting up Hadoop on Windows (via Cygwin) along with the corresponding Eclipse plugin for easier Map-Reduce development and deployment. 
Also if your Windows' Account name contains spaces (for example 'my account') some of the tests wont pass and the build will fail.
The easiest solution is to create a new Windows' Account that contains no spaces (for example 'myaccount'), and use that account when Compiling.
{note} 
This will run the default targets, which builds both the core and the examples, and also packages them.

h2. Compile Core
* change to the core directory
* mvn compile

h2. Install Core

Note, you can do install instead of compile.

* change to the core directory
* mvn install 

h2. Compile Examples

*You must "mvn install" the core before you can build the examples.  For some reason Maven doesn't know how to build sibling modules that are dependencies.*

* change to the examples directory
* mvn compile

h2. Compile Taste Web

* change to the taste-web directory
* Edit the recommender.properties value to add in your recommender class.  Make sure the recommender class is available in the classpath (i.e. add it to the WAR that gets created)
* mvn package

h3. Adding your own Taste recommender

Now MAHOUT-110 has been committed, add your recommender JAR file into trunk/taste-web/lib and then edit the recommender.properties file and set the recommender.class property to the fully qualified name of your Recommender.

Then, doing a "mvn package" will bake your JAR file into the WAR file by adding it to WEB-INF/lib and setting the recommender.properties file will automatically configure the web.xml to use it.

h3. Deploying Taste Web
Instructions for deploying and getting a taste of Taste Web can be found at the [documentation section|http://lucene.apache.org/mahout/taste.html#demo]

h2. Working With Maven in Eclipse
We've used Eclipse Galileo and m2eclipse 0.9 and the 'import maven projects' feature. Check out the mahout sources into your workspace directory, do a full build on the command-line and then fire up the import in Eclipse from File > Import > Maven Projects. Point it at the mahout root directory. You are then given the opportunity to choose which sub-modules to import. You don't need to import them all, only the projects you are interested in working with.

This sets up one Eclipse project for each of the mahout sub-modules you chose. Inter-project dependencies are automatically resolved. For example, if mahout-core and mahout-math are both open the m2eclipse plugin will automatically set up a project dependency on mahout-math in mahout-core. If you close mahout-math, the plugin will automatically revert to a jar dependency for mahout-math.

If you are importing mahout-collections/mahout-math you will have to add the target/generated-sources directories to your build path manually and do a refresh on the dependent projects. Alternatively just avoid importing these (or close them) and they will be treated as a regular jar dependency. This works much better than doing the checkout into Eclipse directly via the m2eclipse 'check out maven projects from scm' importer. 

h2. For Eclipse users on Mac OS X Leopard
These instructions work on  Mac OSX Leopard 10.5.6 and Eclipse 3.3.2 
# Get the [source code|#Get the Source Code]. You can use [Subclipse plugin|http://subclipse.tigris.org/servlets/ProjectProcess?pageID=p4wYuA] for Eclipse
# Install Maven plugin for eclipse through the update site present in [M2Eclipse|http://m2eclipse.codehaus.org/]
# JDK 1.6
Since hadoop requires jdk 1.6, Mahout also needs jdk 1.6 and you would have to make sure JRE 1.6 is added to Eclipse. 
To use JRE 1.6 for Mahout, go to Preferences --> Java --> Installed JREs --> Click Add and specify 
## JRE type as "standard VM"
## JRE Name as "JVM 1.6" and
## JRE home directory as /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home and click Ok
## Select this new JVM (JVM 1.6) and click Ok
# Building Mahout - Right-click on the mahout project and choose "run as" --> "maven project"

h2. Common problems building Mahout

Sometimes the compilation may fail. Depending on the error type the tips below may help.

* Type 1: "artifact not found, please download and install it manually" --> clean maven repository and try again
{code}
rm -rf ~/.m2/
{code}

* Type 2: "build failed because of a single test - 1 test failed, Failures: 1"  --> retry compilation from clean (you may need to clean the ~/.m2 directory above)
{code}
mvn clean install
{code}

* Type 3 (MacOSX only): Wrong Java Version

Problem: There is an error 'javac: invalid target release: 1.6' even though Java 6 is set to be the default in the Java Preferences. Even on the command line, 'java -version' showed 1.6 as the version number. However, this did not carry over to Maven, as 'mvn -v' confirmed.

Solution: Explicitly set the 'JAVA_HOME' environment variable. Strangely enough, this does not happen automatically when changing the Java Preferences.  In my case, I set it via 'export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/'


* Type 4: Out of Memory when compiling

Problem: 'java.lang.OutOfMemoryError: Java heap space' when compiling the core module of a current svn checkout of Mahout (not the release).

Solution: Set the environment variable 'MAVEN_OPTS' to allow for more memory via 'export MAVEN_OPTS=-Xmx1024m'


Change your notification preferences: http://cwiki.apache.org/confluence/users/viewnotifications.action