How to use this plugin?

There are fundamentally 3 methods to use this plugin:

  1. Using Archetypes provided in the Maven Alfresco SDK
  2. By using the Alfresco SDK Parent POM
  3. Via direct configuration in your POM

Method 1 - Using Maven Alfresco SDK Archetypes

Two sample archetypes already use the plugin and provide best practice example on how to use it:

  1. The Alfresco AMP Archetype provides a sample of AMP packaging
  2. The Alfresco All-in-One Archetype provides a sample using AMPs as dependencies and WAR overlay

This is the recommended and less error-prone way of using the plugin.

Method 2 - Using Maven Alfresco SDK Parent POM

The Maven Alfresco SDK Parent POM provides a single entry point for all SDK features.

By using it as parent as follows:

<project>
     ...
     <parent>
        <groupId>org.alfresco.maven</groupId>
        <artifactId>alfresco-sdk-parent</artifactId>
        <version>1.0</version>
    </parent>
    ...
</project>

you will have automatic support for AMP packaging of your project (just add you sources in src/main/amp).

Method 3 - Direct configuration in POM

If you want more control over the plugin behavior you can use it directly in your POM.

NOTE: The following configuration is not required when using the SDK parent, as it's already included there.

In order to manage AMP artifacts with the Alfresco Maven plugin you need to:

  • Declare the plugin in your POM with <extensions> enabled, to allow AMP packaging lifecycle:
    <project>
      [...]
      <build>
        <plugins>
          ...
          <plugin>
              <groupId>org.alfresco.maven.plugin</groupId>
              <artifactId>alfresco-maven-plugin</artifactId>
              <version>1.1.0</version>
              <extensions>true</extensions>
            </plugin>
            ...
        </plugins>
      </build>
      [...]
    </project>
  • If you want to package an Alfresco Module Package from your amp packaging project you also need to make sure your AMP content gets copied to $project.build.directory/$project.build.finalName so the plugin can pick them up. Supposing your AMP sources are in src/main/amp you should configure the following <resource> block:
    <project>
      [...]
      <build>
        <resources>
            ...
            <resource>
                <directory>src/main/amp</directory>
                <!-- This is relative to ${project.build.outputDirectory} -->
                <targetPath>../${project.build.finalName}</targetPath>
                <filtering>${app.filtering.enabled}</filtering>
            </resource>
        </resources>
      </build>
      [...]
    </project>