header_visibility: footer_visibility:
lang: en

Alfresco Maven Blog

Calendar June 28, 2013 | User Bill Young

Alfresco’s adoption of Maven has matured significantly over the last couple years.  As of Enterprise version 4.1.2, Maven is fully supported for building both the Alfresco and share web applications, as well as providing well-structured archetypes for AMP development.  In this blog, I’ll discuss some of the new features and advantages of using these evolving capabilities.

Maven Archetypes

There are a couple Alfresco custom Maven archetypes which will be of interest to Alfresco developers.


AMP Archetype

Bill-Young_AlfrescoMavenBlog12The AMP archetype provides the structure for a typical AMP.  The user may specify to which web application (Alfresco or share) the AMP is targeted.  The plugin which builds the AMP uses this to create the appropriate structure for the resulting package.  Contrast this with existing examples of Ant processes which differ based on the author’s preferences and require more procedural management of the construction of the AMP package.  A typical AMP project folder structure is shown in the diagram. Of particular note is the src/main/amp directory structure, which mimics exactly to layout the module in the Alfresco web application.  The web directory provides locations for scripts and other material which will be downloaded to the user’s browser environment. Prior to the recent release of the AMP archetype and plugin, the POM for an AMP project was quite complex.  With the maturity of the new plugin, a much simpler POM results in generation of the AMP package.


All-in-One Archetype

Bill-Young_AlfrescoMavenBlog21The All-in-One Archetype provides a multi-module project which can be used as a starting point for customization of both the repository (Alfresco) and UI (share) web applications. Dependencies on the web applications are automatically created. A sample AMP project for merging with the Alfresco web application exists, along with the necessary POM construction for including the sample AMP in the Alfresco web application.







Creating an Alfresco Project

Starting a new Alfresco Maven project is streamlined, as usual with Maven, by use of the command:

mvn archetype:generate

to build the project structure.  To see the list of available Alfresco Maven archetypes, issue the command:

mvn archetype:generate -DarchetypeCatalog= -Dfilter=org.alfresco.maven.archetype:

The results of this command should look something like this:

Choose archetype:
 1: -> org.alfresco.maven.archetype:alfresco-amp-archetype (Sample project with full support for lifecycle and rapid development of AMPs (Alfresco Module Packages))

 2: -> org.alfresco.maven.archetype:alfresco-allinone-archetype (Sample multi-module project for All-in-One development on the Alfresco platform. Includes modules for: Repository, AMP, Share, Solr, Web Quick Start and embedded Jetty run)

Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains):

Building the Project

Building the web applications and all dependencies is as simple as issuing the one line Maven command:

mvn install

As is common with Maven, the first time build can take quite a while, as the plugins and dependencies are downloaded to the local Maven repository.  After the first time, building is much faster, though as usual with large web applications, it can take several minutes to build the full project.  Contrast this, however, with individually applying the MMT (module management tool) for each AMP.  The POM declares the dependencies, and the packaging of the WAR files resolves these to apply MMT to the AMPs.  The dependencies in the web application POMs are very simply expressed.  Java libraries may be expressed using typical Maven dependencies.  AMPs, which must be “overlayed” onto the Alfresco or Share WAR, are specified in the configuration section of the maven-war-plugin, as shown here:

          <!-- The Alfresco WAR -->
            <!-- To allow inclusion of META-INF -->
          <!-- Add / order your AMPs here -->
     </build>Using the Archetypes


As with many things Alfresco, one of the first places to look for help is the Alfresco wiki: The Maven Alfresco SDK home page provides a more complete reference for use of the above described features: And the Maven Alfresco Lifecycle Discussion Group provides a forum for questions and answers, which is monitored closely by the engineers responsible for the Maven Alfresco SDK:!forum/maven-alfresco


The maturing of Alfresco’s support for Maven as a build and project management environment is a welcome addition to this powerful CMS.  The more natural construction of the AMP projects reflects the deployment of the AMP contents to the web application.  This helps the developer in making minor modifications during development and testing.  The archetypes simplify project creation.  The POMs are greatly simplified over earlier versions.  All this simplifies the work on developers and release engineers, making for smoother, more repeatable build and deployment practices.

©2022 Flatirons Solutions, Inc.|All Rights Reserved|Privacy Policy
Follow Flatirons Solutions