This section gives a brief overview of how to prepare Maven for building Fuse ESB Enterprise projects and introduces the concept of Maven coordinates, which are used to locate Maven artifacts.
In order to build a project using Maven, you must have the following prerequisites:
Maven installation—Maven is a free, open source build tool from Apache. You can download the latest version from the Maven download page. The minimum supported version is 2.2.1.
Network connection—whilst performing a build, Maven dynamically searches external repositories and downloads the required artifacts on the fly. By default, Maven looks for repositories that are accessed over the Internet. You can change this behavior so that Maven will prefer searching repositories that are on a local network.
![[Note]](imagesdb/note.gif)
Note Maven can run in an offline mode. In offline mode Maven will only look for artifacts in its local repository.
In order to access artifacts from the FuseSource Maven repository, you need to add
it to Maven's settings.xml file. Maven looks for your
settings.xml file in the .m2 directory of the
user's home directory. If there is not a user specified settings.xml
file, Maven will use the system-level settings.xml file at
M2_HOME/conf/settings.xml.
To add the FuseSource repository to Maven's list of repositories, you can either
create a new .m2/settings.xml file or modify the system-level
settings. In the settings.xml file, add the
repository element for the FuseSource repository as shown in
bold text in Example 4.
Example 4. Adding the FuseSource Repositories to Maven
<settings>
<profiles>
<profile>
<id>my-profile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>fusesource</id>
<url>http://repo.fusesource.com/nexus/content/groups/public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>fusesource.snapshot</id>
<url>http://repo.fusesource.com/nexus/content/groups/public-snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>apache-public</id>
<url>https://repository.apache.org/content/groups/public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
...
</repositories>
</profile>
</profiles>
...
</settings>The preceding example also shows repository element for the following repositories:
fusesource-snapshotrepository—if you want to experiment with building your application using an Fuse ESB Enterprise snapshot kit, you can include this repository.apache-publicrepository—you might not always need this repository, but it is often useful to include it, because Fuse ESB Enterprise depends on many of the artifacts from Apache.
The basic building block in the Maven build system is an artifact. The output of an artifact, after performing a Maven build, is typically an archive, such as a JAR or a WAR.
A key aspect of Maven functionality is the ability to locate artifacts and manage
the dependencies between them. Maven defines the location of an artifact using the
system of Maven coordinates, which uniquely define the
location of a particular artifact. A basic coordinate tuple has the form,
{. Sometimes Maven augments the basic
set of coordinates with the additional coordinates,
groupId,
artifactId,
version}packaging and classifier.
A tuple can be written with the basic coordinates, or with the additional
packaging coordinate, or with the addition of both
the packaging and classifier
coordinates, as follows:
groupdId:artifactId:versiongroupdId:artifactId:packaging:versiongroupdId:artifactId:packaging:classifier:version
Each coordinate can be explained as follows:
groupdIdDefines a scope for the name of the artifact. You would typically use all or part of a package name as a group ID—for example,
org.fusesource.example.artifactIdDefines the artifact name (relative to the group ID).
versionSpecifies the artifact's version. A version number can have up to four parts:
n.n.n.n, where the last part of the version number can contain non-numeric characters (for example, the last part of1.0-SNAPSHOTis the alphanumeric substring,0-SNAPSHOT).packagingDefines the packaged entity that is produced when you build the project. For OSGi projects, the packaging is
bundle. The default value isjar.classifierEnables you to distinguish between artifacts that were built from the same POM, but have different content.
The group ID, artifact ID, packaging, and version are defined by the corresponding elements in an artifact's POM file. For example:
<project ... >
...
<groupId>org.fusesource.example</groupId>
<artifactId>bundle-demo</artifactId>
<packaging>bundle</packaging>
<version>1.0-SNAPSHOT</version>
...
</project>For example, to define a dependency on the preceding artifact, you could add the
following dependency element to a POM:
<project ... >
...
<dependencies>
<dependency>
<groupId>org.fusesource.example</groupId>
<artifactId>bundle-demo</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
...
</project>![]() | Note |
|---|---|
It is not necessary to specify the |








