Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Download and install Maven.
    (Maven 23.21.1 or better newer is required to build Camel 2.5 14 onwards).
    (Maven 3.02.2 5 or better newer is required to build Camel 2.10 18 onwards). 
    (Maven 3.03.4 3 or better newer is required to build Camel 2.11 20 onwards). 
  • Get the latest Source
  • Java
    (1.7 or 1.68 to build Camel 2.14 onwards)
    (Java 1.5 is @deprecated and no longer supported from 8 to build Camel 2.7 18 onwards)
    (Java 1.7 is supported from 9 experimental support for building Camel 2.10 19 onwards)

Optional:

  • Prince should be in the executable PATH to generate the PDF documentation

Maven options

To build camel maven has to be configured to use more memory:

Unix/Linux/Mac
Code Block
languagetext

export MAVEN_OPTS="-Xms3000m -Xmx1024mXmx3000m -XX:MaxPermSize=512m"
Windows
Code Block
languagetext

set MAVEN_OPTS=-Xms3000m -Xmx1024mXmx3000m -XX:MaxPermSize=512m

To conserve memory with Java 8 you can set two additional Java options -XX:+UseG1GC to enable G1 garbage collector (default in Java 9) and -XX:+UseStringDeduplication to help decrease Maven memory usage (up to 1.5GB is required currently, but set it a higher):

Unix/Linux/Mac
Code Block
languagetext
export MAVEN_OPTS="-Xmx2G -XX:+UseG1GC -XX:+UseStringDeduplication"
Windows
Code Block
languagetext
set MAVEN_OPTS=-Xmx2G -XX:+UseG1GC -XX:+UseStringDeduplication

You can try to experiment with parallel builds by adding -T1.5C to MAVEN_OPTS, but be wary as some of the plugins are not thread safe, and the console output will be intertwined. With parallel builds and when using the install goal you might experience race conditions with the local repository, using Takari Concurrent Local Repository will help with that.

A normal build

Code Block
languagetext

mvn clean install

A normal build without running tests

Code Block
languagetext

mvn clean install -Pfastinstall

A normal build without running tests but checkstyle verification enabled

Code Block
languagetext

mvn clean install -Pfastinstall,sourcecheck

...

The following skips building the manual, the distro and does not execute the unit tests.

Code Block
languagetext

mvn install -Pfastinstall

Using an IDE

If you prefer to use an IDE then you can auto-generate the IDE's project files using maven plugins. e.g.

IntelliJ

Code Block

mvn idea:idea

Eclipse

There are several ways to import the projects into Eclipse.

m2e

At this point, usage of the m2e plugins to import Camel into Eclipse does not work due to plugins without LifeCycle hints, bundle plugin configuration problems, etc... Patches, notes, etc... to help get this supported would be more than welcome.

maven-eclipse-plugin

The maven-eclipse-plugin can be used to generate the .classpath/.project/.settings file that Eclipse need. To do this, run:

Code Block

mvn process-test-sources eclipse:eclipse
Tip
titleEnable the apt Profile explicitly if using Java 6

Per default this profile is enabled only when using Java 7+ however for many of the Camel components you would still need the org.apache.camel:spi-annotations Maven module on the class path inside the generated .classpath. To force this on Java 6 do:

Code Block

mvn -Papt process-test-sources eclipse:eclipse

As otherwise some of the Camel components inside your eclipse workspace would not compile (when using Java 6) because the org.apache.camel:spi-annotations Maven module would be missing on the class path.

or

Code Block

mvn -Psetup.eclipse -Declipse.workspace.dir=/path/to/your/workspace

The latter is recommended as it would completely setup the workspace for you as well as provide options to wire in other projects also found in your workspace.

After running the above command, from within Eclipse, do "File -> Import -> Existing Projects into Workspace", select the root camel checkout location and Eclipse should find all the projects.

Adding Camel Eclipse templates to your workspace

The above mentioned setup.eclipse profile does a few additional things to your workspace:

  1. Adds the Camel code templates (see here)
  2. Sets the M2_REPO variable in the workspace that points to your local Maven repository (i.e., ~/.m2/repository on Unix and c:\Documents and Settings\<user>\.m2\repository on Windows) which allows the jars to be resolved.
Hint: specify the workspace location in your .m2/settings.xml

You can add a profile to your .m2/settings.xml to specify your eclipse workspace location so you can avoid having to type that each time you need to update the projects.

...


<profiles>
    <profile>
        <id>setup.eclipse</id>
        <properties>
            <eclipse.workspace>/path/to/your/workspace</eclipse.workspace>
        </properties>
    </profile>
</profiles>

Updating the license headers

Proper license headers are enforced using Apache RAT and Checkstyle Maven plugins. To make it less tedious and error prone you can update the license headers by using:

Code Block
languagetext
mvn -Plicense license:format

This can be invoked from any module, which makes it useful when working on components. You can find the various license headers that the Camel project uses in buildtools/src/main/resources/header-*.txt files. These are regenerated at build time from header.txt in the same directory.

Building source

Building with checkstyle

To enable source style checking with checkstyle, build Camel with the -Psourcecheck parameter

Code Block

mvn -Psourcecheck clean install

Building source jars

If you want to build jar files with the source code, that for instance Eclipse can important so you can debug the Camel code as well. Then you can run this command from the camel root folder:

Code Block
languagetext

mvn clean source:jar install -Pfastinstall

Building with Spring 3.0

...

Support for Spring 3.0 is deprecated from Camel 2.11 onwards.

From Camel 2.11.0 onwards, if you want Camel to be build against Spring 3.0 you have to build with the maven profile spring3.0.

Code Block

mvn clean install -Pspring3.0

...

From Camel 2.10.0 onwards, if you want Camel to be build against Spring 3.1 you have to build with the maven profile spring3.1.

Code Block

mvn clean install -Pspring3.1

From Camel 2.11.0 onwards, Spring 3.1 is the default.

Note: the camel-test-spring component requires to be built with Spring 3.1.

Building with Spring 3.2

From Camel 2.11.0 onwards, if you want Camel to be build against Spring 3.2 you have to build with the maven profile spring3.2.

Code Block

mvn clean install -Pspring3.2

From Camel 2.12.0 onwards, Spring 3.2 is the default.

...

Working with karaf features

If you change anything in the features.xml from platform/karaf you can run a validation step to ensure the generated features.xml file is correct. You can do this running the following maven goal from the platform directory.

Code Block
languagetext

mvn clean install -Pvalidate

Executing unit tests using Ekstazi

Normally, when you execute the unit tests during your development cycle for a particular component, you are executing all the tests each time. This may become inefficient, when you are changing one class and the effect of this change is limited within the component having many unit tests. Ekstazi is a regression testing tool that can keep track of the test results and the changed classes so that unaffected tests can be skipped during the subsequent testing. For more details of Ekstazi, please refer to the Ekstazi page at http://www.ekstazi.org.

To use Ekstazi, you can run the tests with the maven profile ekstazi.

Code Block
languagetext
mvn test -Pekstazi

See Also