Maven Erlang Plug-In

The Maven Erlang Plug-In manages Erlang projects under Maven2, enabling building, testing and deployment - as expected by Maven users.

This project is based on the ideas of maven-erlang, created by Paul Guyot and Olivier Sambourg, but is maintained under this new regime in order to improve and extend it. This incarnation also provides a little bit more definition for development - be sure to check it out if you are interested in contributing.

Prerequisites

You will need to have maven2 and erlang version R13B04 or later installed.

Getting started

The plug-in is available from the Sonatype OSS Repository https://oss.sonatype.org/. Add this to your POM plugins section:

...
<plugin>
  <groupId>eu.lindenbaum</groupId>
  <artifactId>maven-erlang-plugin</artifactId>
  <version>1.0.0-beta</version>
  <extensions>true</extensions>
</plugin>
...

Or you may check out the source code from the repository and install it locally.

 svn co https://erlang-plugin.svn.sourceforge.net/svnroot/erlang-plugin/tags/maven-erlang-plugin-1.0.0-beta maven-erlang-plugin
 cd maven-erlang-plugin/
 mvn install

This will build, test, package and install the plug-in.

To install the download version of the plug-in you need to extract the provided package and install the .jar artifacts with the following:

 tar xzvf maven-erlang-plugin-1.0.0-beta.tar.gz
 
 cd maven-erlang-plugin-1.0.0-beta
 
 mvn install:install-file \
    -Dfile=maven-erlang-plugin-1.0.0-beta.jar \
    -DgroupId=eu.lindenbaum \
    -DartifactId=maven-erlang-plugin \
    -Dversion=1.0.0-beta \
    -Dpackaging=jar
    
 mvn install:install-file \
    -Dfile=maven-erlang-plugin-1.0.0-beta-javadoc.jar \
    -DgroupId=eu.lindenbaum \
    -DartifactId=maven-erlang-plugin \
    -Dversion=1.0.0-beta \
    -Dpackaging=jar \
    -Dclassifier=javadoc
    
 mvn install:install-file \
    -Dfile=maven-erlang-plugin-1.0.0-beta-sources.jar \
    -DgroupId=eu.lindenbaum \
    -DartifactId=maven-erlang-plugin \
    -Dversion=1.0.0-beta \
    -Dpackaging=jar \
    -Dclassifier=sources

Packaging Type

Two custom components are defined in the plug-in, and can be used by configuring the packaging type of a project.

  • erlang-otp - An application development project, aimed at supporting the conventions of the Erlang OTP Design Principles respecting the default maven2 directory layout.
  • erlang-rel - A release and packaging project that supports building an erlang/OTP packaged and distributable solution.

Configuration

Here is an example of the minimum required configuration for any project that wishes to use the Maven Erlang Plug-In:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>[your-gropupId]</groupId>
  <artifactId>[your-artifactId]</artifactId>
  <version>[your-version]</version>
  <packaging>erlang-otp</packaging>                       <-- erlang-otp or erlang-rel
  <build>
    <plugins>
      <plugin>
        <groupId>eu.lindenbaum</groupId>
        <artifactId>maven-erlang-plugin</artifactId>
        <version>1.0.0-beta</version>
        <extensions>true</extensions>                     <-- required
      </plugin>
    </plugins>
  </build>
</project> 

Directory Structure

This is the default directory structure that is supported for projects, and in part also generated, by the plug-in. Please note that some target folders that are common to Maven projects e.g. site are omitted in this listing.

erlang-otp
 BASE
   +-- src
   |     +-- main
   |     |     +-- erlang (*.erl, *.app, *.appup, *.mib, *.funcs)
   |     |     +-- include (*.hrl)
   |     |     +-- priv (*)
   |     |     +-- resources
   |     |     |     +-- priv (*)
   |     |    [+-- *] (other non-erlang source folders)
   |     |
   |     +-- test
   |           +-- erlang (*.erl)
   |           +-- include (*.hrl)
   |           +-- resources (*)
   |
   +-- target (.dialyzer.ok)
   |     +-- ebin (*.beam, *.app, *.appup)
   |     +-- lib (dependency applications)
   |     +-- include (*.hrl)
   |     +-- mibs (*.bin)
   |     +-- priv (*)
   |     +-- surefire-reports (TEST-*.xml)
   |     +-- test (*.beam, *.hrl)
   |    [+-- *_src] (non-erlang source folders)
   |
   +-- pom.xml
erlang-rel
 BASE
   +-- src
   |     +-- main
   |           +-- erlang (*.rel, *.relup)
   +-- target (.dialyzer.ok)
   |     +-- ebin (*.rel, *.relup)
   |     +-- lib (dependency applications)
   |     +-- releases (previous/subsequent releases)
   +-- pom.xml

Goals

The tables below shows how the plug-in goals are mapped to the Maven default lifecycle.

erlang-otp
Maven lifecycle phaseGoal in the Maven Erlang Plug-In
generate-sourcesunpack-dependencies
generate-resourcescopy-resources
compilecompile
generate-test-resourcescopy-test-resources
test-compiletest-compile
process-test-classesdialyzer
testtest
packagepackage
erlang-rel
Maven lifecycle phaseGoal in the Maven Erlang Plug-In
generate-sourcesunpack-dependencies
process-resourcescopy-resources
compiledialyzer-release
process-classesprepare-release
packagepackage-release

Setup

Provides the option to generate sensible defaults, replacing the need for a maven archetype.

More information:

Run

There is a plug-in goal to run an erlang-otp packaged project for basic testing purposes. It will start an interactive erlang shell with sasl which is able to start the application. The goal ends up in the shell in order to provide interactive access to the started application.

More information:

Reports

There are also plug-in goals that provide output for site generation, such as EDoc and source code test coverage reports.

More information: