Managing Alfresco Lifecyle with Maven
From AlfrescoWiki
| This page was created and is maintained by an Alfresco Partner. | |
| Name: | Sourcesense |
| Logo: |
|
| Website | http://www.sourcesense.com |
| Email: | alfresco@sourcesense.com |
| Description | Making sense of open source. |
[edit] Maven Alfresco Lifecycle
[edit] 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.
A mailing list is also available in Google Groups at maven-alfresco at googlegroups dot com .
[edit] Usage Scenarios
- 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
[edit] Prerequisites
- Tested with Apache Maven 2.2.1 on MacOSX Leopard, JDK 1.6.0_15
Feel free to add here more platform you tested this against.
[edit] How to manage Alfresco Repository Extensions (alfresco/extension Spring based WAR builds)
[edit] 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.
[edit] Project creation
Interactive mode
You can access the interactive mode command line project creation by running:
mvn archetype:generate -DarchetypeCatalog=http://maven.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=com.sourcesense.alfresco -DarchetypeArtifactId=maven-alfresco-extension-archetype -DarchetypeVersion=1.9.1 \ -DgroupId=com.mycompany -DartifactId=myalfresco -Dversion=1.0-SNAPSHOT -DarchetypeRepository=http://maven.alfresco.com/nexus/content/repositories/releases -DinteractiveMode=false
[edit] 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).
[edit] NEW!!! How to manage Alfresco Share Extensions (alfresco/web-extension Spring customization WAR builds)
[edit] 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.
[edit] Project creation
[edit] Interactive
You can simply access the interactive mode command line project creation by running:
mvn archetype:generate -DarchetypeCatalog=http://maven.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.
[edit] 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=1.9.1 -DgroupId=com.mycompany -DartifactId=mycustomshare \ -Dversion=1.0-SNAPSHOT -DarchetypeRepository=http://maven.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)
[edit] SHARE 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
Main features are described in the Maven documentation site.
[edit] How to manage Alfresco AMPs (alfresco/module/* based AMP builds) with Maven
[edit] 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.
[edit] Project creation
[edit] Interactive
You can simply run the following command from a terminal or command prompt:
mvn archetype:generate -DarchetypeCatalog=http://repository.sourcesense.com/nexus/content/repositories/alfresco.public.releases/archetype-catalog.xml
then selecting the maven-alfresco-amp-archetype option and filling in your company details.
[edit] 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=com.sourcesense.alfresco -DarchetypeArtifactId=maven-alfresco-amp-archetype -DarchetypeVersion=1.9.1 -DgroupId=com.mycompany \ -DartifactId=myamp -Dversion=1.0-SNAPSHOT -DarchetypeRepository=http://maven.alfresco.com/nexus/content/repositories/releases -DinteractiveMode=false
[edit] 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".
[edit] AMPs usage
Test and install your AMP package:
mvn install
Deploy to a Maven remote repo
mvn deploy
[edit] 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 and enforcing of best practices like ${pom.groupId}.{pom.artifactId} = moduleId
[edit] Maven Repositories
[edit] Maven repositories and Alfresco POMs
ATM archetypes don't use Alfresco POMs, because they are not officially available. An unofficial copy can be found in the project maven4alfresco.
Surf and Webscript frameworks components should soon have official POM due to the contribution to Spring. Stay tuned here :)
[edit] New Alfresco Community Maven Repository
A public repository hosting archetypes, plugins and Alfresco community artifacts (with groupId org.alfresco) is hosted by Alfresco at:
Releases Repo Snapshots Repo Alfresco Sites Repo
New Community artifacts will be made available here.
[edit] 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:
Sourcesense Snapshots Alfresco Repo Sourcesense Releases Alfresco Repo Sourcesense Sites Alfresco Repo
This repository is now deprecated for new releases of Alfresco artifacts.
[edit] Resources
Maven Alfresco Discussion Group
old m2alfresco archetypes project


