Using Maven to Build WSO2 Products

You can use Maven to build products from the WSO2 repositories that you clone to your computer. Following are the prerequisites, the build commands, and the order in which you build the repositories. Before you begin, see WSO2 GitHub Repositories.

Prerequisites for using Maven

  • Install Maven and JDK. For compatible versions, see the Installation Prerequisites topic in the documentation for the product you're working with.

  • Set the environment variable MAVEN_OPTS="-Xmx2048M -XX:MaxPermSize=1024m" to avoid the Maven OutOfMemoryError.

  • Make sure the build server has an active Internet connection to download dependencies while building.

Maven build commands

You use one of the following Maven commands to build your repositories and create complete release artifacts of a WSO2 product, including the binary and source distributions.

Command Description
mvn clean install The binary and source distributions.
mvn clean install -Dmaven.test.skip=true The binary and source distributions, without running any of the unit tests.
mvn clean install -Dmaven.test.skip=true -o The binary and source distributions, without running any of the unit tests, in offline mode. This can be done only if you have already built the source at least once.

Note: If you get the error "Comparison method violates its general contract" while building the Carbon Kernel repository, use the java.util.Arrays.useLegacyMergeSort JVM parameter with the Maven command as follows:

_JAVA_OPTIONS=-Djava.util.Arrays.useLegacyMergeSort=true mvn clean install

Building a WSO2 product

  1. Build all the component-level repositories that you have cloned to your computer and edited. Be sure that you build the repositories in the correct order. Email dev@wso2.org if you need help.

  2. Once you have built the component-level repositories, build the product-level repository that you have cloned to your computer.
  3. When you build the product repository, Maven will first check in the local Maven repository on your computer and fetch the repositories that you built in Step 1. Maven will then fetch the remaining dependent repositories from Nexus. This process will give you a new product pack with your changes.

You can find the new binary pack (ZIP file) in the <PRODUCT_REPOSITORY_HOME>/modules/distribution/target directory, which you can use to distribute the product if needed.

© WSO2