Starting Project with Apache Servicemix

Creating the projects

We are going to create 3 Maven projects:

  • a servicemix-camel SU project
  • a servicemix SA project
  • a parent project to hold the previous two

Create the parent project

Start by creating a new directory to hold your project. Add a pom.xml file to it:

<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.apache.servicemix.tutorial.camel</groupId>
  <artifactId>parent</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>SMX-Camel :: Tutorial</name>
  <url>http://servicemix.apache.org</url>
</project>

Create the servicemix-camel SU project

Use the servicemix-camel-service-unit Maven archetype to create a first SU project inside the parent directory:


mvn archetype:create -DarchetypeArtifactId=servicemix-camel-service-unit \
-DarchetypeGroupId=org.apache.servicemix.tooling -DartifactId=tutorial-camel-su

Create the SA project and add the SU

Use the servicemix-service-assembly Maven archetype to create the SA project:


mvn archetype:create -DarchetypeArtifactId=servicemix-service-assembly \
-DarchetypeGroupId=org.apache.servicemix.tooling -DartifactId=tutorial-camel-sa

Don’t forget to add the SU as a dependency to the SA’s pom.xml:


<project>
  ...
  <dependencies>
    <dependency>
      <groupId>org.apache.servicemix.tutorial.camel</groupId>
      <artifactId>tutorial-camel-su</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>
  </dependencies>
  ...
</project>

Cleaning up and doing a first build.

Just do a quick clean-up of the generated pom.xml files (e.g. changing the project names to get more comprehensible logging output) and build the entire project using the command mvn install in the parent project directory. If everything is OK, the output should look like:


[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO]   SMX-Camel :: Tutorial
[INFO]   SMX-Camel :: Tutorial :: Camel SU
[INFO]   SMX-Camel :: Tutorial :: SA
[INFO] ------------------------------------------------------------------------
[INFO] Building SMX-Camel :: Tutorial
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
...
[INFO] ------------------------------------------------------------------------
[INFO] Building SMX-Camel :: Tutorial :: Camel SU
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
...
[INFO] ------------------------------------------------------------------------
[INFO] Building SMX-Camel :: Tutorial :: SA
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
...
[INFO] [install:install]
[INFO] Installing /home/gert/projects/tutorial/tutorial-camel-sa/target/tutorial-camel-sa-1.0-SNAPSHOT.jar
to /home/gert/.m2/repository/org/apache/servicemix/tutorial/camel/tutorial-camel-sa/1.0-SNAPSHOT/tutorial-camel-sa-1.0-SNAPSHOT.zip
[INFO]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] SMX-Camel :: Tutorial ................................. SUCCESS [5.549s]
[INFO] SMX-Camel :: Tutorial :: Camel SU ..................... SUCCESS [7.849s]
[INFO] SMX-Camel :: Tutorial :: SA ........................... SUCCESS [0.381s]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14 seconds
[INFO] Finished at: Fri Feb 15 10:39:06 CET 2008
[INFO] Final Memory: 21M/79M
[INFO] ------------------------------------------------------------------------

Now that we have created the necessary projects, it’s time to really get started with camel

Advertisements

About this entry