Quantcast
Viewing latest article 1
Browse Latest Browse All 12

Maven and Alfresco

Image may be NSFW.
Clik here to view.
Last week I spent several hours automating the creation of an Alfresco development environment using bash scripts–copying sample project files, customizing Ant scripts and properties, creating databases, etc. While taking a break and surfing the web, I read several recommendations for Apache Maven. A few years have passed since I last touched Maven and I remembered it being pretty easy to use. I also remembered some chatter in Alfresco circles about an official Maven repository for Alfresco, so I decided to dig a little deeper to see if Maven could help me out. I was unprepared for just how slick–and fun!–it would end up being.

I started reading a few wiki pages and blog posts posts explaining approaches for using Maven to manage Alfresco development. Although a good starting point, they didn’t quite get me where I wanted, which was a complete Alfresco and Share extension project that I could drop code into and be on my way, building, testing and deploying. Then I found Martin Bergljung’s post. Well-written and thorough with a great sample project, his post lined everything up and my project started falling into place. Martin does an excellent job of explaining project organization, the various components of the projects’ POMs, and how everything ties together. After following his instructions, I was looking at a nice “BUILD SUCCESS” message and was ready to start developing.

In addition to setting up a development environment for an existing project, I wanted to establish a process for doing the same for new work. Currently, I make a copy of Michael McCarthy’s repository and Share demo projects, update the build properties, and re-configure the Ant build scripts. While writing a bash script to automate this, I realized that is precisely what Maven does using project archetypes. Using the test project I now had building from Martin’s blog post, I decided to try creating my own archetype to repeat the process for a new project.

This turned out to be easier than expected with the command:

mvn archetype:create-from-project

Once I took a sweep through the project to make all titles and descriptions generic enough, I generated the archetype project and was able to then build and install it to my local repository. Now I can use the following command with this new archetype to create a new, customized project:

mvn archetype:generate -DarchetypeGroupId=com.tribloom -DarchetypeArtifactId=alfresco-extensions-archetype -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=com.yourcompany -DartifactId=yourArtifactId

While I realize there are existing Alfresco archetypes, I found Martin’s to be immediately applicable to the work I’ve been doing and wanted to teach myself a bit about Maven project and archetype configuration.

To see the archetype code or try it out yourself, check out my alfresco-extensions-archetype GitHub repo.


Viewing latest article 1
Browse Latest Browse All 12

Trending Articles