Maven and Erlang

From Erlang Community

(Difference between revisions)
Revision as of 11:20, 6 October 2006 (edit)
213.171.204.166 (Talk)

← Previous diff
Current revision (23:53, 11 April 2007) (edit) (undo)
VenIsh (Talk | contribs)
m
 
(10 intermediate revisions not shown.)
Line 2: Line 2:
'''This is a two-part article''' '''This is a two-part article'''
-Thist part deals with installing Maven and maven-erlang plugin for Maven+This part deals with installing Maven and maven-erlang plugin for Maven
[[Maven_and_Erlide|The second part]] will deal with using Maven with Erlide [[Maven_and_Erlide|The second part]] will deal with using Maven with Erlide
===What is Maven?=== ===What is Maven?===
-Maven is a software project management tool. Though it was initially developed to handle Java projects, thanks to it plugin system you can use it for other types of projects as well.+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=== ===Maven and Erlang===
Thanks to [http://maven-erlang.sourceforge.net/ maven-erlang] you can use Maven to handle Erlang projects. Thanks to [http://maven-erlang.sourceforge.net/ maven-erlang] you can use Maven to handle Erlang projects.
-Erlang + Maven combination lets you do the following:+Erlang Maven combination lets you do the following:
* compile your entire project * compile your entire project
* use [http://support.process-one.net/doc/display/CONTRIBS/EUnit EUnit] to do automatic testing * use [http://support.process-one.net/doc/display/CONTRIBS/EUnit EUnit] to do automatic testing
* package all project directories, OTP-style, into a single .zip file * package all project directories, OTP-style, into a single .zip file
-* deploy: create necessary directories for an OTP-type distribution+* deploy: deploy the zip file to a remote location (via FTP, SCP, WebDAV, etc.)
-The last two steps create the following directory structure:+The packaged project has the following directory structure:
./ ./
--- doc --- doc
Line 25: Line 25:
--- include --- include
--- src --- src
 +
===Installing Maven=== ===Installing Maven===
You may also refer to [http://maven.apache.org/download.html#Installation official instructions] You may also refer to [http://maven.apache.org/download.html#Installation official instructions]
-# Download an install JDK: [http://sdlc4a.sun.com/ECom/EComActionServlet;jsessionid=23E30092E96A51EEDEDC58557E569BA0 here]+# Download and install JDK: [http://sdlc4a.sun.com/ECom/EComActionServlet;jsessionid=23E30092E96A51EEDEDC58557E569BA0 here]
# Download Maven [http://maven.apache.org/download.html here]. # Download Maven [http://maven.apache.org/download.html here].
# Unzip/untar the archive to any directory of your choosing # Unzip/untar the archive to any directory of your choosing
Line 41: Line 42:
# As a last step I would also recommend creating the following '''mvncreate.bat''' file in **maven/bin** so as to save yourself some typing: # 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 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 an Erlang project using Maven===
# Create a directory somewhere wehre you want to test everything works and go there # Create a directory somewhere wehre you want to test everything works and go there
Line 66: Line 68:
<!-- CHANGE THE FOLLOWING PATHS --> <!-- CHANGE THE FOLLOWING PATHS -->
<!-- *********************** --></pre> <!-- *********************** --></pre>
- <erlPath>path_to_your_Erlng_installation/bin/erl.exe</erlPath>+ <erlPath>path_to_your_Erlang_installation/bin/erl.exe</erlPath>
<eunitPath>path_to_EUnit/eunit-1.1/</eunitPath> <eunitPath>path_to_EUnit/eunit-1.1/</eunitPath>
</configuration> </configuration>
Line 74: Line 76:
</project> </project>
 +
 +<ol start="4">
 +<li>You'll also have to configure the ''<distributionManagement>'' section of your ''pom.xml'' file if you want to use the ''deploy'' goal. More information is available on the [http://maven.apache.org/plugins/maven-deploy-plugin/usage.html maven-deploy-plugin homepage]. You can also use another deployment plugin such as [http://maven.apache.org/wagon/ Wagon] (e.g. for DAV support)</li>
 +</ol>
 +
===Using Maven=== ===Using Maven===
-# Go into '''Core''' directory+# Go into '''Core''' directory (if your project's name is '''Core''')
-# '''mvn compile''' will compile your project and will place the resulting beam files into '''Core/target'''+# '''mvn compile''' will compile your project files from '''src/main/erlang''' and place the resulting beam files into '''target/ebin'''
-# '''mvn test''' will run all tests in '''src/test'''+# '''mvn test''' will compile all test files from '''src/test/erlang''', place the beam files into '''target/test''' and run the ''test/0'' function for every module which name ends with '''_test'''
-# '''mvn package''' will create a .zip file in '''Core/traget'''+# '''mvn package''' will create a .zip file in '''target/''' (after compiling the project and running the test)
-# '''mvn deploy''' will create OTP directory structure in '''Core/target'''+# '''mvn deploy''' will deploy the .zip file according to the ''<distributionManagement>'' section of your POM file
-''Note:'' package and deploy require EUnit+''Note:'' test and subsequent goals require EUnit
[[Category:HowTo]] [[Category:HowTo]]

Current revision

Contents

[edit] Notice

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

[edit] 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.

[edit] 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: deploy the zip file to a remote location (via FTP, SCP, WebDAV, etc.)

The packaged project has the following directory structure:

    ./
       --- doc
       --- ebin
       --- include
       --- src

[edit] Installing Maven

You may also refer to official instructions

  1. Download and install JDK: here
  2. Download Maven here.
  3. Unzip/untar the archive to any directory of your choosing
  4. Create/Update the following environment variables:
     JAVA_HOME: path_to_jdk         PATH: path_to_maven/bin
  5. Type mvn --version in console. If you see version displayed, you've done everything correctly. Otherwise check your JDK installation and paths
  6. Create a directory named, e.g., erlang-plugin and perform an svn checkout on https://svn.sourceforge.net/svnroot/maven-erlang/erlang-plugin/trunk
  7. Create a directory named, e.g., erlang-archetype and perform an svn checkout on https://svn.sourceforge.net/svnroot/maven-erlang/erlang-archetype/trunk
  8. Go into erlang-plugin and type mvn install. During installation Maven will download any additional dependencies required
  9. Go into erlang-archetype and type mvn install.
  10. Download and unpack EUnit: here
  11. We've installed everything we need!
  12. 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

[edit] Create an Erlang project using Maven

  1. Create a directory somewhere wehre you want to test everything works and go there
  2. 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
  3. 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_Erlang_installation/bin/erl.exe</erlPath>
     <eunitPath>path_to_EUnit/eunit-1.1/</eunitPath>
    </configuration>
   </plugin>
  </plugins>
 </build>

</project>
  1. You'll also have to configure the <distributionManagement> section of your pom.xml file if you want to use the deploy goal. More information is available on the maven-deploy-plugin homepage. You can also use another deployment plugin such as Wagon (e.g. for DAV support)

[edit] Using Maven

  1. Go into Core directory (if your project's name is Core)
  2. mvn compile will compile your project files from src/main/erlang and place the resulting beam files into target/ebin
  3. mvn test will compile all test files from src/test/erlang, place the beam files into target/test and run the test/0 function for every module which name ends with _test
  4. mvn package will create a .zip file in target/ (after compiling the project and running the test)
  5. mvn deploy will deploy the .zip file according to the <distributionManagement> section of your POM file

Note: test and subsequent goals require EUnit

Erlang/OTP Projects
Personal tools