How to create an Alfresco Module Package (AMP)

In this post I will set up the basic settings to create an Alfresco Module Package (AMP). Ant needs to be installed to make this work. This creates a skeleton AMP module that does nothing except being a module. So the first step is to create a new project in your favorite IDE.

In the Alfresco SDK there are some great examples, and one of them is named SDK Basic AMP. AMP’s have a specific directory structure that it’s wise to use. When deploying AMP’s the Module Management Tool (mmt) maps the files to specific locations in the alfresco tree. This can be a bit confusing when dealing with configuration files and if the SDK samples have solved a problem in a specific way, it’s wise to just follow that road.

1. Create a file containing these lines:
# Skeleton AMP Module
module.description=Add a skeleton amp to Alfresco

This file contain module information and is to be located in the root of the amp. Usually the file is located in the IDE at config/alfresco/module/modulename/ (IDE) config/alfresco maps to alfresco_dir/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/.

2. Create a config/alfresco/module/skeleton/module.context file:
<?xml version='1.0' encoding='UTF-8'?>


This is where one puts bean initializations, bootstrap resource bundles, adds webclient configuration files etc. when needed.

3. Place class files (if you have any) in source/java/my/namespace/*.java

4. Sample build.xml for ant:
<?xml version="1.0"?>

<project name="Skeleton" default="deploy-war" basedir=".">
<!-- Project directories, REPLACE WITH YOUR SETTINGS -->
<property name="project.dir" value="."/>
<property name="build.dir" value="${project.dir}/build"/>
<property name="jar.file" value="${build.dir}/lib/skeleton.jar" />
<property name="amp.file" value="${build.dir}/dist/skeleton.amp"/>
<property name="tomcat.dir" value="/opt/Alfresco/tomcat" />
<property name="war.file" value="${tomcat.dir}/webapps/alfresco.war"/>
<property name="lib.dir" value="/opt/alfresco-sdk2.9/lib/server" />

<!-- Path to essential libraries -->
<path id="class.path">
<dirset dir="${build.dir}" />
<fileset dir="${lib.dir}" includes="**/*.jar"/>

<!-- Creates a build directory where the amp and jar files will be located -->
<target name="mkdirs">
<mkdir dir="${build.dir}/dist" />
<mkdir dir="${build.dir}/lib" />

<target name="package-jar" depends="compile">
<delete file="${jar.file}" />

<jar destfile="${jar.file}">
<fileset dir="${build.dir}" includes="**/faces-config.xml, **/*.class" />

<target name="package-amp" depends="mkdirs, package-jar" description="Packages the amp">
<zip destfile="${amp.file}">
<fileset dir="${project.dir}/build" includes="lib/*.jar" />
<fileset dir="${project.dir}" includes="" />
<fileset dir="${project.dir}" includes="config/**/*.*" />

<!-- Use when checking what deployment of an AMP will do without actually committing the deployment -->
<target name="preview-install">
<echo>Preview installation of AMP</echo>
<java dir="." fork="true" classname="org.alfresco.repo.module.tool.ModuleManagementTool">
<classpath refid="class.path" />
<arg line="install ${amp.file} ${war.file} -preview -force -verbose"/>

<!-- Deploys the war to Alfresco -->
<target name="deploy-war" depends="package-amp">
<java dir="." fork="true" classname="org.alfresco.repo.module.tool.ModuleManagementTool">
<classpath refid="class.path" />
<arg line="install ${amp.file} ${war.file} -force -verbose"/>


An AMP file is a zipped archive, so if you would like to know the content of the amp then:
unzip skeleton.amp

To view the content of a jar file:
jar -tvf skeleton.jar

SDK Basic AMP example – This is the basic AMP taken from the SDK.

Alfresco Module Packages
Alfresco SDK


About Haridasi

integrity - the state of being whole, entire, or undiminished.
This entry was posted in Technology and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *