Maven and Erlang
This is a two-part article
This part deals with installing Maven and maven-erlang plugin for Maven
The second part will deal with using Maven with Erlide
What is Maven?
Maven is a software project management tool. Though it was initially developed to handle Java projects, thanks to its plugin system you can use it for other types of projects as well.
Maven and Erlang
Thanks to maven-erlang you can use Maven to handle Erlang projects.
Erlang + Maven combination lets you do the following:
- compile your entire project
- use EUnit to do automatic testing
- package all project directories, OTP-style, into a single .zip file
- deploy: create necessary directories for an OTP-type distribution
The last two steps create the following directory structure:
./ --- doc --- ebin --- include --- src
You may also refer to official instructions
- Download and install JDK: here
- Download Maven here.
- Unzip/untar the archive to any directory of your choosing
- Create/Update the following environment variables:
JAVA_HOME: path_to_jdk PATH: path_to_maven/bin
- Type mvn --version in console. If you see version displayed, you've done everything correctly. Otherwise check your JDK installation and paths
- Create a directory named, e.g., erlang-plugin and perform an svn checkout on https://svn.sourceforge.net/svnroot/maven-erlang/erlang-plugin/trunk
- Create a directory named, e.g., erlang-archetype and perform an svn checkout on https://svn.sourceforge.net/svnroot/maven-erlang/erlang-archetype/trunk
- Go into erlang-plugin and type mvn install. During installation Maven will download any additional dependencies required
- Go into erlang-archetype and type mvn install.
- Download and unpack EUnit: here
- We've installed everything we need!
- As a last step I would also recommend creating the following mvncreate.bat file in **maven/bin** so as to save yourself some typing:
mvn archetype:create -DarchetypeGroupId=org.erlang.maven -DarchetypeArtifactId=erlang-archetype -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=%1 -DartifactId=%2
Create an Erlang project using Maven
- Create a directory somewhere wehre you want to test everything works and go there
- Type the following: mvncreate Test Core (this will create a project named Core in the group named Orcas). You can see the directories created by Maven here
- In directory Core open the pom.xml file and edit it:
<project> <modelVersion>4.0.0</modelVersion> <groupId>Test</groupId> <artifactId>Core</artifactId> <packaging>erlang-otp</packaging> <version>1.0-SNAPSHOT</version> <name>Test Core</name> <url>some url</url> <build> <plugins> <plugin> <groupId>org.erlang.maven</groupId> <artifactId>erlang-plugin</artifactId> <extensions>true</extensions> <configuration>
<!-- Required parameter : absolute path to the erlang binary !--> <!-- *********************** --> <!-- CHANGE THE FOLLOWING PATHS --> <!-- *********************** -->
<erlPath>path_to_your_Erlng_installation/bin/erl.exe</erlPath> <eunitPath>path_to_EUnit/eunit-1.1/</eunitPath> </configuration> </plugin> </plugins> </build> </project>
- Go into Core directory
- mvn compile will compile your project and will place the resulting beam files into Core/target
- mvn test will run all tests in src/test
- mvn package will create a .zip file in Core/traget
- mvn deploy will create OTP directory structure in Core/target
Note: package and deploy require EUnit