...
Creating the Maven Projects for Each Component
Creating a
...
Maven Subproject For the JBI Service Engine
The focus of this section is on the creation of a JBI component. For this task, a Maven archetype will be used to create a Maven project skeleton to house the component. Maven archetypes are templates for Maven projects that jumpstart project creation via the automation of repetitive tasks by following standard conventions. The result of using an archetype to create a Maven project is a directory structure, a Maven POM file and, depending on the archetype being used, sometimes Java objects and JUnit tests.
...
Panel |
---|
$ mvn archetype:create \ |
...
The first three parameters to the mvn
command (-DarchetypeGroupId=org.apache.servicemix.tooling -DarchetypeArtifactId=servicemix-service-engine -DarchetypeVersion=3.1-incubating-SNAPSHOT) identify which Maven archetype to use for the archetype:create
goal, while the last two parameters (-DgroupId=org.apache.servicemix.samples.helloworld -DartifactId=hello-world-se) uniquely identify the Maven project that is being generated. The groupId
(printed in pink) is used as the Java package and the artifactId
is used as the project name. Therefore, only alphanumeric characters are valid values for the groupId
and artifactId
parameters.
...
Note | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||
The maven-archetype-plugin 1.0-alpha4 or above is required for this tutorial. When an older version is installed, a build error will occur. The version of this plugin can be checked by verifying the name of the following directories:
In case the only version available is an older one, a minimal
|
Creating the
...
Maven Subprojects For the Service Unit and Service Assembly
The archetypes for SUs and SAs do not contain much code, but rather help with tasks related to Maven. Later, we will only need to adapt the POMs to our project - just little work.. Below are the steps for to achieve this:
1) From within the hello-world-smx
directory, execute the following commands to create the project for the SU:
Code Block |
---|
$ mvn archetype:create \ -DarchetypeGroupId=org.apache.servicemix.tooling \ -DarchetypeArtifactId=servicemix-service-unit \ -DarchetypeVersion=3.1-incubating-SNAPSHOT \ -DgroupId=org.apache.servicemix.samples.helloworld \ -DartifactId=hello-world-su |
...
Code Block |
---|
$ mvn archetype:create \ -DarchetypeGroupId=org.apache.servicemix.tooling \ -DarchetypeArtifactId=servicemix-service-assembly \ -DarchetypeVersion=3.1-incubating-SNAPSHOT \ -DgroupId=org.apache.servicemix.samples.helloworld \ -DartifactId=hello-world-sa |
Upon successful execution of the archetype:create
goal goals, look for the BUILD SUCCESSFUL
output. The hello-world-smx
directory should now contain the following directories:
Code Block |
---|
hello-world-sa
hello-world-se
hello-world-su
|
If you see the above directories, proceed to the next section.
If instead you see the BUILD FAILED
output, you'll need to look at analyze the rest of the output to troubleshoot the issue. In case this success information does not appear, the output will provide some information about what might have gone awry. Assistance with any issue you might experience is available from the ServiceMix community via the ServiceMix mailing lists archive.
Incorporating the
...
Subprojects Into a Top Level POM
Now that we have created the SU and SA projects, a the top level pom.xml
must be manually created and made aware of each onesubproject. In the hello-world-se
directory create a file named pom.xml
containing the following content:
Code Block |
---|
<?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.samples</groupId> <artifactId>hello-world-se</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <name>Hello World JBI Sample</name> <modules> <module>hello-world-sa</module> <module>hello-world-su</module> </modules> <dependencies> <dependency> <groupId>org.apache.servicemix.samples.helloworld</groupId> <artifactId>hello-world-su</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> </project> |
This POM will allow this the example to be easily folded in to the ServiceMix samples. The <modules>
element denotes the child projects subprojects that were created using the Maven archetypes and the <dependencies>
element tells Maven to include the SU into the SA when it is constructed.
Give Each of the
...
Maven Subprojects a Name
When sitting in the hello-world-smx
directory, you should now see the following:
...
- Edit
hello-world-sa/pom.xml
and change replace<name>a custom project</name>
with<name>Hello World Service Assembly</name>
- Edit
hello-world-se/pom.xml
and change replace<name>a custom project</name>
with<name>Hello World Service Engine</name>
- Edit
hello-world-su/pom.xml
and change replace<name>a custom project</name>
with<name>Hello World Service Unit</name>
...
According to the archetype rules, all Java objects generated from the archetype:create
goal are prefixed with the word My. The Java objects can be renamed to whatever you prefer, making sure to also change the names in the corresponding resource files (and all tests and {{pom.xml}}s) as well.
...
In order to, among other things, build and package the components, execute the following command from within hello-world-smx
directory:
...