Posts /

From the grounds up, your Maven powered Alfresco dev box

Twitter Facebook Google+
14 Jan 2010

mint alf mvn The target ———- To start your Alfresco development experience, you need a development environment. Let’s say you’re more into this Maven and you’d rather leverage its capabilities instead of using the default ant based build system provided along with the SDK. In this tutorial, I’ll guide you through the process of setting up from scratch your development environment. And by saying “from scratch”, I really mean it: we’ll start from a fresh installed Linux box and the we will add piece over piece until we’ll be see the Alfresco flower on our browser. This will be a basic tutorial, just to put in place the foundation for later improvements.

I’m actually performing these steps in a virtual machine, so that next time a quick&dirty Alfresco PoC is required I might use this very same VM to start right away from a known, dev ready point.

UPDATE: the Maven project structure I end up with at the end of this article can be downloaded directly from GitHub.

Operating System

Ok, I assume you know your stuff and don’t want to get a bore-some lesson on how to install Linux. The whole internet is polluted by billions of guides and tutorial since 199x, anyway, so let’s just say I just completed the install process of Mint7 and I’m at my very first login. I would go for Mint8 if my current connection was fast enough to download it before I finish writing these notes, but whatever, there’s nothing really bad in v7.

Tools

The shopping list here includes a JDK, Maven and… well, that should be it, theoretically. Unfortunately, due to a nasty regression, we’re going to need a db. My choice goes to MySQL.

MySQL

First thing first, let’s install it:

~$ sudo apt-get install mysql-server

When this is done, we have to create the db Alfresco is going to use:

~$ mysql -u root
mysql> CREATE DATABASE alf_jetty;
mysql> GRANT ALL ON alf_jetty.* TO 'alfresco'@'%' IDENTIFIED BY 'alfresco';

Username and password are the default for the maven stuff we’re going to use.

Java

Java™ 5 has already passed on, let it rest in peace. Instead, go and install Java™ 6:

~$ sudo apt-get install sun-java6-jdk
[/code]

Maven

Hold on the temptation of installing Maven 3 or to ask apt-get to do this task for you. We’re going to the official download page and following the links to get the latest stable 2.x release. You should end up with something like apache-maven-2.2.1-bin.tar.bz2 on your file system. Then do the following:

~$ cs /opt
~$ sudo tar xvjf apache-maven-2.2.1-bin.tar.bz2
~$ sudo ln -sfv /opt/apache-maven-2.2.1/bin/mvn /usr/bin/mvn

There are less intrusive ways to bring your downloaded application into your PATH, but this is the quickest possible. Let’s go on to the next step.

Plumbing

We’re almost there, we just have to lay down our projects. Let’s start with the Alfresco repo extension:

~$ mkdir -p development/alfresco-showcase
~$ cd development/alfresco-showcase
alfresco-showcase$ wget http://download.skuro.tk/alfresco-showcase/pom.xml
alfresco-showcase$ mvn archetype:generate -DarchetypeGroupId=com.sourcesense.alfresco \
 -DarchetypeArtifactId=maven-alfresco-extension-archetype \
 -DarchetypeVersion=1.9.1 \
 -DgroupId=it.sk.alfresco \
 -DartifactId=alfresco-showcase-extension \
 -Dversion=1.0-SNAPSHOT \
 -DarchetypeRepository=http://maven.alfresco.com/nexus/content/repositories/releases \
 -DinteractiveMode=false

The POM I’m making available here is just a very basically one, I’m using it here just for you to speed up the process.

UPDATE: as others pointed me out, it looks like you somehow need to download such a pom for the whole thing to stand up. That’s simply not true, I’m just building a more complex dev environment and it’s better if we have some structure in place. This includes having a parent project, along with its parent pom, with nested projects registered as its modules. These will come in the next posts. But that’s just part of the reason for this pom to be here: I also tend to be lazy, so that letting you download it was easier than explaining myself. Note to self: thou shalt not post anything at 2am.

First achievement

Ok, let’s stop here now and see what we’ve done by now. Go to the alfresco-showcase folder and type:

alfresco-showcase$ MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m" \
 mvn clean install -Prun

This will start a local jetty instance where Alfresco 3.2 community will be deployed. So, if you now point your browser to http://localhost:8080/alfresco you will finally see that flower we talked about at the beginning of this post.

Next steps

That’s it for now, but other blocks are still missing: what about AMPs? And WCM? And does Share fits in the picture? I’ll cover all the points in the next episodes of this series. See you there!


Twitter Facebook Google+