Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
4.5. Generating a Custom Offline Repository
Use case for a custom offline repository Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
When you move from the development phase of a project to the deployment phase, it is typically more convenient to pre-install all of the artifacts required by your application, rather than downloading them from the Internet on demand. In this case, the ideal solution is to create a custom offline repository, which contains the artifacts needed for your deployment. Creating a custom offline repository by hand, however, would be difficult, because it would need to include all of the transitive dependencies associated with your application bundles and features.
The ideal way to create a custom offline repository is to generate it, with the help of the Apache Karaf
features-maven-plugin plug-in.
features-maven-plugin Maven plug-in Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The
features-maven-plugin plug-in from Apache Karaf is a utility that is used internally by the Apache Karaf developer community and the Red Hat JBoss Fuse development team to create distributions of the Apache Karaf OSGi container. Some of the goals of this plug-in are also useful for application developers, however, and this section explains how you can use the add-features-to-repo goal to generate your own custom offline repository.
Important
At present, only the
add-features-to-repo goal of the features-maven-plugin plug-in is supported.
Steps to generate a custom repository Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
To generate and install a custom offline repository for specific Apache Karaf features, perform the following steps:
Create a POM file Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
In a convenient location—for example,
ProjectDir—create a new directory, ProjectDir/custom-repo to hold the Maven project. Using a text editor, create the project's POM file, pom.xml, in the custom-repo directory and add the following contents to the file:
This is the bare bones of a Maven POM, which will be added to in the following steps. There is no need to specify a Maven package type here (it defaults to
jar), because no package will be generated for this project.
Add the features-maven-plugin Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Continue editing the
pom.xml and add the features-maven-plugin as shown (where the build element is inserted as a child of the project element):
Subsequent steps will explain how to specify the descriptor list (of features repositories) and the features list.
Specify the features to download Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
In this example scenario, it is assumed that you want to make the
camel-jms feature and the camel-quartz feature available in offline mode. List all of the features you want to download and store in the offline repository in the features element, which is a child of the configuration element of the features-maven-plugin.
To make the
camel-jms and camel-quartz features available offline, add the following features element as a child of the feature-maven-plugin's configuration element:
<features> <feature>camel-jms</feature> <feature>camel-quartz</feature> </features>
<features>
<feature>camel-jms</feature>
<feature>camel-quartz</feature>
</features>
Specify the feature repositories Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
A feature repository is a location that stores feature descriptor files. Generally, because features can depend recursively on other features and because of the complexity of the dependency chains, the project normally requires access to all of the standard Red Hat JBoss Fuse feature repositories.
To see the full list of standard feature repositories used by your installation of JBoss Fuse, open the
etc/org.apache.karaf.features.cfg configuration file and look at the featuresRepository setting, which is a comma-separated list of feature repositories, like the following:
Now, add the listed feature repositories to the configuration of the
features-maven-plugin in your POM file. Open the project's pom.xml file and add a descriptor element (as a child of the descriptors element) for each of the standard feature repositories. For example, given the preceding value of the featuresRepositories list, you would define the features-maven-plugin descriptors list in pom.xml as follows:
Specify the Red Hat JBoss Fuse system repository Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Add the Red Hat JBoss Fuse system repository,
EsbInstallDir/system, to the list of repositories in the pom.xml file. This is necessary for two reasons: first of all, it saves you from downloading Maven artificats that are already locally available from your JBoss Fuse installation; and secondly, some of the artifacts in the system repository might not be available from any of the other repositories.
Using a text editor, open
pom.xml and add the following repositories element as a child of the project element, customizing the file URL to point at your local system repository:
Specify the remote repositories Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Generally, the project requires access to all of the standard JBoss Fuse remote repositories. To see the full list of standard remote repositories, open the
etc/org.ops4j.pax.url.mvn.cfg configuration file and look at the org.ops4j.pax.url.mvn.repositories setting, which is a comma-separated list of URLs like the following:
Each entry in this list must be converted into a
repository element, which is then inserted as a child element of the respositories element in the project's pom.xml file. The preceding repository URLs have slightly different formats and must be converted as follows:
RepoURL- The value of the repository URL,
RepoURL, is inserted directly into theurlchild element of therepositoryelement. For example, thehttp://repo1.maven.org/maven2repository URL translates to the followingrepositoryelement:Copy to Clipboard Copied! Toggle word wrap Toggle overflow RepoURL@snapshots- The
@snapshotssuffix indicates that downloading snapshots should be enabled for this repository. When specifying the value of theurlelement, remove the@snapshotssuffix from the URL. Change thesnapshots/enabledflag totrue, as shown in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow RepoURL@snapshots@noreleases- The combination of the
@snapshotssuffix and the@noreleasessuffix indicates that downloading snapshots should be enabled and downloading releases should be disabled for this repository. When specifying the value of theurlelement, remove both suffixes from the URL. Change thesnapshots/enabledflag totrueand change thereleases/enabledflag tofalse, as shown in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Generate the offline repository Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
To generate the custom offline repository, open a new command prompt, change directory to
ProjectDir/custom-repo, and enter the following Maven command:
mvn generate-resources
mvn generate-resources
Assuming that the Maven build completes successfully, the custom offline repository should now be available in the following location:
ProjectDir/custom-repo/target/features-repo
ProjectDir/custom-repo/target/features-repo
Install the offline repository Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
To install the custom offline repository in the JBoss Fuse container, edit the
etc/org.ops4j.pax.url.mvn.cfg file and append the offline repository directory to the list of default repositories, as follows:
org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}/${karaf.default.repository}@snapshots,ProjectDir/custom-repo/target/features-repo@snapshots
org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}/${karaf.default.repository}@snapshots,ProjectDir/custom-repo/target/features-repo@snapshots
The
@snapshots suffix can be added to the offline repository URL, if there is a possibility that some of the artifacts in it are snapshot versions.