Este conteúdo não está disponível no idioma selecionado.
Chapter 7. Patching Red Hat Fuse application
Using the new patch-maven-plugin
mechanism you can apply a patch to your Red Hat Fuse application. This mechanism allows you to change the individual versions provided by different Red Hat Fuse BOMS, for example, fuse-springboot-bom
and fuse-karaf-bom
.
7.1. About patch-maven-plugin Copiar o linkLink copiado para a área de transferência!
The patch-maven-plugin
performs following operations:
- Retrieve the patch metadata related to current Red Hat Fuse BOMs.
-
Apply the version changes to
<dependencyManagement>
imported from the BOMs.
After the patch-maven-plugin
fetches the metadata, it iterates through all managed and direct dependencies of the project where the plugin was declared and replaces the dependency versions (if they match) using CVE/patch metadata. After versions are replaced, Maven build continues and progresses through standard Maven project stages.
7.2. Applying patch to Red Hat Fuse applications Copiar o linkLink copiado para a área de transferência!
The purpose of patch-maven-plugin is to update the versions of the dependencies listed in the Red Hat Fuse BOM to the versions specified in the patch metadata of the patch that you wish to apply to your applications.
Procedure
Following procedure explains how to apply the patch to your application.
Add
patch-maven-plugin
to your project’spom.xml
file. The version of thepatch-maven-plugin
must be the same as the version of the Fuse BOM.Copy to Clipboard Copied! Toggle word wrap Toggle overflow When you run any one of the
mvn clean deploy
ormvn validate
ormvn dependency:tree
commands, the plugin searches through the project modules to check whether one of Red Hat Fuse BOMs is used. Only two are considered as the supported BOMs:-
org.jboss.redhat-fuse:fuse-karaf-bom
: for Fuse Karaf BOM -
org.jboss.redhat-fuse:fuse-springboot-bom
: for Fuse Spring Boot BOM
-
If none of the above BOMs are found, the plugin will display following messages:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If both Fuse BOMs are found, the
patch-maven-plugin
stops with the following warning:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
patch-maven-plugin
attempts to fetch one of the following Maven metadata values.-
For the projects with Fuse Karaf BOM, the
org.jboss.redhat-fuse/fuse-karaf-patch-metadata/maven-metadata.xml
is resolved. This is the metadata for the artifact with theorg.jboss.redhat-fuse:fuse-karaf-patch-metadata:RELEASE
coordinates. For the projects with Fuse Spring Boot BOM project, the
org.jboss.redhat-fuse/fuse-springboot-patch-metadata/maven-metadata.xml
is resolved. This is the metadata for the artifact with theorg.jboss.redhat-fuse:fuse-springboot-patch-metadata:RELEASE
coordinates.Example metadata generated by Maven
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
For the projects with Fuse Karaf BOM, the
-
The
patch-maven-plugin
parses the metadata to select the version which is applicable to the current project. This is possible only for the Maven projects using Fuse BOM with version 7.8.xxx. Only the metadata that matches the version range 7.8, 7.9 or later is applicable and only the latest version of the metadata is fetched. The
patch-maven-plugin
collects a list of remote Maven repositories to be used when downloading the patch metadata identified bygroupId
,artifactId
andversion
found in previous steps. These Maven repositories are the ones that are listed in the project’s<repositories>
elements in the active profiles and also the repositories fromsettings.xml
file.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optionally, if you wish to use a offline repository, you can use
-Dpatch
option to specify a ZIP file which is produced byfuse-karaf/fuse-karaf-patch-repository
orfuse-springboot/fuse-springboot-patch-repository
modules ofjboss-fuse/redhat-fuse
project. These ZIP files have the same internal structure as the Maven repository structure. For example,Copy to Clipboard Copied! Toggle word wrap Toggle overflow Whether the metadata comes from remote repository, local repository or ZIP file, it is analyzed by the
patch-maven-plugin
. The fetched metadata contains list of CVEs and for each CVE we have a list of affected Maven artifacts (specified by glob patterns and version ranges) together with a version that contains a fix for a given CVE. For example,Copy to Clipboard Copied! Toggle word wrap Toggle overflow Finally a list of fixes specified in patch metadata is consulted when iterating over all managed dependencies in current project. These dependencies (and managed dependencies) that match are changed to fixed versions. For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Skipping the patch
In case when you do not wish to apply a specific patch to your project, the patch-maven-plugin
provides a skip
option. Assuming that you have already added patch-maven-plugin
to project’s pom.xml
file, and you don’t wish for the versions to be altered, you can use one of the following method to skip the patch.
-
Add the skip option to your project’s
pom.xml
file as follows.
-
Or use
-DskipPatch
option when running themvn
command as follows.
As shown in the above output, the patch-maven-plugin
was not invoked, which results in the patch not being applied to the application.