With the tutorial-first-su ready, we are now ready to use a Maven archetype to create a service assembly

Creating the service assembly (SA)

Just as we started our service unit with a Maven archetype, we are also going to use a Maven archetype (servicemix-service-assembly) to create the SA project. Run this command from the directory that holds your parent pom.xml:

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

A new service assembly project is generated in the tutorial-sa directory.

Editing pom.xml

Changing the project name

Again, to clean up the build output, we change the project's name

<?xml version="1.0" encoding="UTF-8"?>
<project>
  ...
  <name>Tutorial :: SA</name>
  ...
</project>

Adding the SU to the SA

We want to add the service unit we created before to the service assembly. The Maven tooling will do this automatically if we add the correct dependency to our SA's pom.xml. We just use the groupId, artifactId and version we find in our service unit's pom.xml here:

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

Running Maven to build everything

Now, run mvn install from the parent directory to get this output:

[INFO] Scanning for projects...
[INFO] Reactor build order: 
[INFO]   Tutorial
[INFO]   Tutorial :: File SU
[INFO]   Tutorial :: SA
[INFO] ----------------------------------------------------------------------------
[INFO] Building Tutorial
[INFO]    task-segment: [install]
[INFO] ----------------------------------------------------------------------------
       ...
[INFO] ----------------------------------------------------------------------------
[INFO] Building Tutorial :: File SU
[INFO]    task-segment: [install]
[INFO] ----------------------------------------------------------------------------
       ...
[INFO] ----------------------------------------------------------------------------
[INFO] Building Tutorial :: SA
[INFO]    task-segment: [install]
[INFO] ----------------------------------------------------------------------------
       ...
[INFO] [jar:jar]
[INFO] Building jar: /home/gert/projects/tutorial/tutorial-sa/target/tutorial-sa-1.0-SNAPSHOT.jar
       ...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Tutorial .............................................. SUCCESS [0.981s]
[INFO] Tutorial :: File SU ................................... SUCCESS [7.110s]
[INFO] Tutorial :: SA ........................................ SUCCESS [0.927s]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9 seconds
[INFO] Finished at: Mon Jul 30 16:23:42 CEST 2007
[INFO] Final Memory: 23M/56M
[INFO] ------------------------------------------------------------------------

Now, we are ready to deploy our service assembly. If you have followed the previous tutorial, you already know how to do this using the hot-deploy directory. In our next step, we are going to use the Maven tooling for deployment.

Further reading

Things to remember

  • You can use the servicemix-service-assembly archetype to quickly create a Maven SA project.
  • Add SU to your SA by adding dependencies to your pom.xml