Managing Alfresco Lifecyle with Maven

cancel
Showing results for 
Search instead for 
Did you mean: 

Managing Alfresco Lifecyle with Maven

resplin
Intermediate
0 0 5,563

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com




Table of Contents


Important note


This page refers to an old version of the Maven support for Alfresco (pre Alfresco 4.x).
If you are using Alfresco Community 4.2.b+ or Alfresco Enterprise 4.1.2+, It is recommended now to use the new Maven Alfresco SDK 1.0.


Maven Repositories


Alfresco Artifacts Repository (formerly Maven Alfresco Community Repository)


A public repository hosting archetypes, plugins, Alfresco community  (and enterprise as of June 2012) artifacts (with groupId  org.alfresco and org.alfresco.enterprise respectively) is hosted  by Alfresco at:

Releases Repo
Snapshots Repo
Alfresco Sites Repo

New  Community and Enterprise artifacts will be made available here. See the  dedicated wiki page for more details.


Maven repositories and Alfresco POMs


ATM archetypes don't use Alfresco POMs, because they are not officially available. Please vote for this issue if you wish to suggest Alfresco to make POMs available.


Old Maven 2 support infra


Until version 1.0.0 of Maven Alfresco Lifecycle (1.9.0 of Maven Alfresco Archetypes),
a public repository hosting archetypes, plugins and Alfresco community artifacts (with groupId org.alfresco) was  available at Sourcesense

This repository is now deprecated for new releases of Alfresco artifacts.


Maven Alfresco Lifecycle (obsolete)


If you are using Alfresco Community 4.2.b+ or Alfresco Enterprise 4.1.2, It is recommended now to use the new Maven Alfresco SDK 1.0.


How To for Dummies


A GREAT intro tutorial has been created here https://wiki.alfresco.com/wiki/Maven_For_Dummies
OUT OF DATE

If you are instead interested in the whole potential, please read on.


SDK Usage Scenarios


  • Check the project page for supported / core use cases
  • Enterprise Integration (see NXP Maven integration case)
  • Alfresco used as enterprise content application framework
  • Controlled environments
  • Open source communities
  • Looking at Spring Surf extension for providing an advances Surf archetype

History


This page is intended to gather all efforts and achievements in the integration between Alfresco and Apache Maven,
especially focusing on managing Alfresco applications (extensions + AMPs) in enterprise environments started as of year 2007.

It's important to understand that this approach does *not* require Alfresco to be built with Maven, but provides support for integrating development *on top* of Alfresco with Apache Maven.

This project tries to merge efforts by the two forge projects maven4alfresco (maven-amp-plugin v.2.0.0 is assumed) and m2alfresco. The archetype project is hosted in Google Code while binaries are deployed on Alfresco Community Maven repository.

The whole support is wrapped under the name of Maven Alfresco Lifecycle and includes Archetypes and Plugins latest versions.


Prerequisites


Tested with


  • Apache Maven 2.2.1 on MacOSX Leopard, JDK 1.6.0_15
  • Apache Maven 3.0.3 on MacOSX Snow Leopard, JDK 1.6.0_29

Feel free to add here more platform you tested this against.


How to manage Alfresco Repository Extensions (alfresco/extension Spring based WAR builds)


Solution


Use the maven-alfresco-extension-archetype to create WAR packaged webapps that can provide all Maven lifecycle and features. You can also use Maven standard dependency management to pull in AMPs in your build.
See details in the Maven Documentation Site.


Project creation


Interactive mode

You can access the interactive mode command line project creation by running:

mvn archetype:generate -DarchetypeCatalog=https://artifacts.alfresco.com/nexus/content/repositories/releases/archetype-catalog.xml

then selecting the maven-alfresco-extension-archetype option and filling in your company details.

One liner

An even faster and non interactive (edit the groupId and artifactId matching your company information) one liner to create your project is:

mvn archetype:generate -DarchetypeGroupId=org.alfresco -DarchetypeArtifactId=maven-alfresco-extension-archetype -DarchetypeVersion=3.9.1 \
-DgroupId=com.mycompany -DartifactId=myalfresco -Dversion=1.0-SNAPSHOT -DarchetypeRepository=https://artifacts.alfresco.com/nexus/content/repositories/releases -DinteractiveMode=false

Customize your Alfresco edition

By default, the Alfresco edition that will be used is community; this information matches with the Maven classifier of the dependencies being fetched. You can customize it by editing the property <alfresco.edition> located in the <properties> section of your generated POM

This option applies to any archetype (mentioned in this page) that directly accesses Alfresco dependencies.


Usage


Run your Alfresco customized WAR in embedded Jetty (point your browser to http://localhost:8080/alfresco/):

 mvn install -Prun

Run your Alfresco customized WAR and clean DB/alf_data :

 mvn install -Prun,initialize

You can control the environmental properties and the build behaviour using properties and profiles (Maven profiles details).


How to manage Alfresco Share WAR Extensions (alfresco/web-extension Spring customization WAR builds)


NOTE: This Feature is only SNAPSHOT and not fully tested.


Solution


Use the maven-alfresco-share-archetype to create and manage Alfresco SHARE customization webapps, which can provide all Maven lifecycle and features to the lightweight SHARE development. Tested against Alfresco 3.2r2, which sample extensions are included. This allows to build a WAR package which then can depend on multiple Share modules (JARs as of Alfresco 3.3) produced with the Maven Alfresco Share Module Archetype (see next section).


Project creation


Interactive


You can simply access the interactive mode command line project creation by running:

mvn archetype:generate -DarchetypeCatalog=https://artifacts.alfresco.com/nexus/content/repositories/releases/archetype-catalog.xml

then selecting the maven-alfresco-share-archetype option and filling in your company details / project version.


One liner


An even faster and non interactive (edit the groupId and artifactId matching your company information) one liner to create your project is:

mvn archetype:generate -DarchetypeGroupId=org.alfresco.maven -DarchetypeArtifactId=maven-alfresco-share-archetype -DarchetypeVersion=3.9.1 \
-DgroupId=com.mycompany -DartifactId=my-custom-share -Dversion=1.0-SNAPSHOT -DarchetypeRepository=https://artifacts.alfresco.com/nexus/content/repositories/releases -DinteractiveMode=false


Note: The Share webapp is packaged with the pattern artifactId.war (e.g. in the example above, mycustomshare.war). Remember this when running Share in Jetty embedded (see below)


Share WAR Extension archetype usage


Run the SHARE in Jetty embedded (default 8081 not to clash with Alfresco running on 8080)

 mvn install -Prun

Package and install the customization

 mvn install

Using Share JAR modules


In order to include in your Share WAR Extension build Share (3.3+) JAR modules (either GA or built with the Maven Alfresco Share Module Archetype of next section) you just need to add a dependency snippet in your pom.xml, something like:

 <dependencies>
   <dependency>
       <groupId>org.alfresco</groupId>
       <artifactId>my-custom-share-module</artifactId>
       <version>1.0.0-SNAPSHOT</version>
       <packaging>jar</packaging>
   </dependency>
</dependencies>

More info


Main features are fully described in the Maven documentation site.


How to manage Alfresco Share JAR Modules (Custom Dashlets, Pages, etc. packaged as JARs since Alfresco 3.3)


Available only from Alfresco 3.3: For background info see: http://blogs.alfresco.com/wp/kevinr/2010/01/28/alfresco-share-33-extensions-and-springsurf/


Solution


Use the maven-alfresco-share-module-archetype to create and manage Alfresco SHARE custom dashlets, pages as JARs. Tested against Alfresco 3.3-SNAPSHOT (latest CI build), which sample extensions are included.
This allows to build a JAR package which then can be depended upon by Share WARs produced with the Maven Alfresco Share Extension Archetype (see previous section) and have the plugin installed at build time.


Project creation


Interactive


You can simply access the interactive mode command line project creation by running:

mvn archetype:generate -DarchetypeCatalog=https://artifacts.alfresco.com/nexus/content/repositories/releases/archetype-catalog.xml

then selecting the maven-alfresco-share-module-archetype option and filling in your company details / project version.


One liner


An even faster and non interactive (edit the groupId and artifactId matching your company information) one liner to create your project is:

mvn archetype:generate -DarchetypeGroupId=org.alfresco.maven -DarchetypeArtifactId=maven-alfresco-share-module-archetype -DarchetypeVersion=3.9.1 \ 
-DgroupId=com.mycompany -DartifactId=my-custom-share-module -Dversion=1.0-SNAPSHOT -DarchetypeRepository=https://artifacts.alfresco.com/nexus/content/repositories/releases -DinteractiveMode=false

Note: The Share webapp is packaged with the pattern artifactId.war (e.g. in the example above, mycustomshare.war). Remember this when running Share in Jetty embedded (see below)


SHARE archetype usage


Once project is created in src/main/resources you already find a sample (tag list) which will be packaged as a Share JAR extension by just

 mvn install

Then you can depend on it using the archetype at the previous section, or just drop the JAR in your Share instance and restart and that will magically install the site tags dashlets in your Share.


How to manage Alfresco AMPs (alfresco/module/* based AMP builds) with Maven


Solution


Use the maven-alfresco-amp-archetype to create
maven-amp-plugin managed webapps which can provide to Alfresco modules all Maven lifecycle and features. Also the maven-amp-plugin is used as a replacement to MMT to unpack AMPs into WARs (typically Alfresco Repository Extensions) builds, using the maven dependency mechanism provided by the maven-amp-plugin.


Project creation


Interactive


You can simply run the following command from a terminal or command prompt:

mvn archetype:generate -DarchetypeCatalog=https://artifacts.alfresco.com/nexus/content/repositories/releases/archetype-catalog.xml

then selecting the maven-alfresco-amp-archetype option and filling in your company details.


One liner


An even faster and non interactive (edit the groupId and artifactId matching your company information) one liner to create your project is:

mvn archetype:generate -DarchetypeGroupId=org.alfresco -DarchetypeArtifactId=maven-alfresco-amp-archetype -DarchetypeVersion=3.9.1 -DgroupId=com.mycompany \
-DartifactId=myamp -Dversion=1.0-SNAPSHOT -DarchetypeRepository=https://artifacts.alfresco.com/nexus/content/repositories/releases -DinteractiveMode=false

POM modification


In the 'pom.xml' file, change the first <version> tag's value from '1.0-SNAPSHOT' to a version number that can be understood by Alfresco, such as '1.2.3.4'.


AMPs usage


Test and install your AMP package:

mvn install

Deploy to a Maven remote repo

mvn deploy

What happens behind the scenes


The maven-amp-plugin is used to manage AMP lifecycle in both archetypes,
providing support for:


  • <packaging>amp</packaging> support provided by the maven-alfresco-amp-archetype
  • AMP transitive dependency management
  • AMP automatic unpacking on top of Alfresco WARs (replacing the need for MMT invocations). See here for use Maven dependency management.
  • Single sourcing for module.properties from POM properties.

Resources


Alfresco Artifacts Repository
Maven Alfresco Discussion Group

Archetypes issue tracking

old m2alfresco archetypes project

old maven4alfresco AMP support project

Related weblog
Development Environment
Maven
AMP
Contributing