2
votes

I would like to understand the consequences of packaging Alfresco extension as jar as opposed to packaging it as AMP. I am asking this question in context of building alfesco.war using maven

Assume that I have an module MyAlfresco, created using All in on Archetype. I want to extend it using my Foo extension. My question is: why would I package as AMP?

If I package Foo as jar and mark it as dependency of MyAlfresco, foo.jar will be placed in WEB-INF/lib.

If I package Foo as AMP, the result will be the same (using overlays), but maven build will take much longer (using overlays makes maven-war-plugin quite slow).

So, in such scenario is there any reason to consider packaging Foo as AMP?

2
Right term is AMP, which stand for Alfresco Module Packaging.Jean-Rémy Revy

2 Answers

5
votes

As per doc, JAR and AMP are two different approaches, leaving Maven aside. In a few words, this is mainly a distribution concern, and probably a standardization one.

JAR :

jar contain java classes, and sometimes static resources. They are added to Share / Alfresco by overloading existing classes. They had to be placed into exploded war in WEB-IF/lib. That suppose you use Tomcat and you app is never removed.

This is not the common case, at least not a cumfortable production one.

AMP

The common structure offer some "standard" development, and leverage Spring / Spring Surf integration.

Moreover AMP and Alfresco tooling provide many mechanism to include and use extensions. It use a module.properties to define version and dependency (like maven a way). You can give an AMP to your production operator (or any admin team), they just have to put the AMP in the amp directory, launch apply_amp.sh (or bat) and all should be installed correctly.

If you give a jar, they are many way to include it, and some are really not recommended. So you have to write a How To.

OK, and Maven ?

Maven was integrated in, there is only two years. It still remains some old configurations and many way to develop.

Consider using the AMP extension archetype if you just want to develop a standalone extension, for community or in professional context.

Use the all-in-one archetype when you mix Share and Alfresco, when you will deliver wars (and not only give the AMP), and when you want to develop many amp related together.

Conclusion

Even if I don't go further into details, AMP IS the standard way to deliver Alfresco's extensions. It comes with good tooling an bring some standards.

Use amp extension packaging for "simple" project. Use all-in-one (multi module) when your matters are more complex.

5
votes

Advantages of JAR packaging over AMP:

  • Works with standard (non-Alfresco) toolset
  • Faster build
  • Easy to grok

Advantages of AMP packaging over JAR:

  • Uses Alfresco's preferred and recommended approach
  • Easily packages up everything your extension may need into a single file including dependent JARs, but excludes the entire Alfresco or Share WARs. This makes it easy to deploy and obvious what is part of your extension and what is part of core Alfresco or Share.
  • Can leverage dependency checks at deployment time (AMPs can have a minimum/maximum Alfresco version and can point to other AMPs on which they depend)