patch:apply

Full name:

org.apache.maven.plugins:maven-patch-plugin:1.2:apply

Description:

Apply one or more patches to project sources.

Attributes:

  • Requires a Maven project to be executed.
  • Binds by default to the lifecycle phase: process-sources.

Optional Parameters

Name Type Since Description
backups boolean - Whether to make backups of the original files before modding them.
Default value is: false.
binary boolean 1.2 apply --binary option to patch command line
Default value is: false.
destFile File - The output file which is the original file, plus modifications from the patch. By default, the file(s) will be patched inplace.
failFast boolean - Flag being true if the desired behavior is to fail the build on the first failed patch detected.
Default value is: true.
failurePhrases List - List of phrases to watch for in the command output from the patch tool. If one is found, it will cause the build to fail. All phrases should be lower-case only. By default, the phrases fail, skip and reject are used.
ignoreWhitespace boolean - Whether to ignore whitespaces when applying the patches.
Default value is: true.
ignoredPatches List - When the strictPatching flag is set, this parameter is useful to mark certain contents of the patch-source directory that should be ignored without causing the build to fail.
naturalOrderProcessing boolean - Setting natural order processing to true will cause all patches in a directory to be processed in a natural order alleviating the need to declare patches directly in the project file.
Default value is: false.
optimizations boolean - Flag to enable/disable optimization file from being written. This file tracks the patches that were applied the last time this goal actually executed. It is required for cases where project-sources optimizations are enabled, since project-sources will not be re-unpacked if they are at least as fresh as the source archive. If we avoid re-unpacking project sources, we need to make sure we don't reapply patches.
Note: If the list of patches changes and this flag is enabled, a "mvn clean" must be executed before the next build, to remove the tracking file.
Default value is: true.
originalFile File - The original file which will be modified by the patch. By default, the patch tool will automatically derive the original file from the header of the patch file.
patchDirectory File - The base directory for the file names specified by the parameter patches.
Default value is: src/main/patches.
patchFile File - The single patch file to apply. This parameter is mutually exclusive with the patches parameter.
patchTrackingFile File - This is the tracking file used to maintain a list of the patches applied to the unpacked project sources which are currently in the target directory. If this file is present, and project-source unpacking is optimized (meaning it won't re-unpack unless the project-sources archive is newer), this goal will not execute and no patches will be applied in the current build.
Default value is: ${project.build.directory}/optimization-files/patches-applied.txt.
patches List - The list of patch file names, supplying the order in which patches should be applied. The path names in this list must be relative to the base directory specified by the parameter patchDirectory. This parameter is mutually exclusive with the patchfile parameter.
removeEmptyFiles boolean 1.1 When set to true, the empty files resulting from the patching process are removed. Empty ancestor directories are removed as well.
Default value is: false.
reverse boolean - Whether to treat these patches as having reversed source and dest in the patch syntax.
Default value is: false.
skipApplication boolean - Whether to skip this goal's execution.
Default value is: false.
strictPatching boolean - Flag that, when set to true, will make sure that all patches included in the patches list must be present and describe the full contents of the patch directory. If strictPatching is set to true, and the patches list has a value that does not correspond to a file in the patch directory, the build will fail. If strictPatching is set to true, and the patch directory contains files not listed in the patches parameter, the build will fail. If set to false, only the patches listed in the patches parameter that have corresponding files will be applied; the rest will be ignored.
Default value is: false.
strip int - The number of directories to be stripped from patch file paths, before applying, starting from the leftmost, or root-est.
Default value is: 0.
targetDirectory File - The target directory for applying patches. Files in this directory will be modified.
Default value is: ${project.build.sourceDirectory}.
useDefaultIgnores boolean - Whether to exclude default ignored patch items, such as .svn or CVS directories.
Default value is: true.

Parameter Details

backups:

Whether to make backups of the original files before modding them.
  • Type: boolean
  • Required: No
  • Default: false

binary:

apply --binary option to patch command line
  • Type: boolean
  • Since: 1.2
  • Required: No
  • Default: false

destFile:

The output file which is the original file, plus modifications from the patch. By default, the file(s) will be patched inplace.
  • Type: java.io.File
  • Required: No

failFast:

Flag being true if the desired behavior is to fail the build on the first failed patch detected.
  • Type: boolean
  • Required: No
  • Default: true

failurePhrases:

List of phrases to watch for in the command output from the patch tool. If one is found, it will cause the build to fail. All phrases should be lower-case only. By default, the phrases fail, skip and reject are used.
  • Type: java.util.List
  • Required: No

ignoreWhitespace:

Whether to ignore whitespaces when applying the patches.
  • Type: boolean
  • Required: No
  • Default: true

ignoredPatches:

When the strictPatching flag is set, this parameter is useful to mark certain contents of the patch-source directory that should be ignored without causing the build to fail.
  • Type: java.util.List
  • Required: No

naturalOrderProcessing:

Setting natural order processing to true will cause all patches in a directory to be processed in a natural order alleviating the need to declare patches directly in the project file.
  • Type: boolean
  • Required: No
  • Default: false

optimizations:

Flag to enable/disable optimization file from being written. This file tracks the patches that were applied the last time this goal actually executed. It is required for cases where project-sources optimizations are enabled, since project-sources will not be re-unpacked if they are at least as fresh as the source archive. If we avoid re-unpacking project sources, we need to make sure we don't reapply patches.
Note: If the list of patches changes and this flag is enabled, a "mvn clean" must be executed before the next build, to remove the tracking file.
  • Type: boolean
  • Required: No
  • Default: true

originalFile:

The original file which will be modified by the patch. By default, the patch tool will automatically derive the original file from the header of the patch file.
  • Type: java.io.File
  • Required: No

patchDirectory:

The base directory for the file names specified by the parameter patches.
  • Type: java.io.File
  • Required: No
  • Default: src/main/patches

patchFile:

The single patch file to apply. This parameter is mutually exclusive with the patches parameter.
  • Type: java.io.File
  • Required: No

patchTrackingFile:

This is the tracking file used to maintain a list of the patches applied to the unpacked project sources which are currently in the target directory. If this file is present, and project-source unpacking is optimized (meaning it won't re-unpack unless the project-sources archive is newer), this goal will not execute and no patches will be applied in the current build.
  • Type: java.io.File
  • Required: No
  • Default: ${project.build.directory}/optimization-files/patches-applied.txt

patches:

The list of patch file names, supplying the order in which patches should be applied. The path names in this list must be relative to the base directory specified by the parameter patchDirectory. This parameter is mutually exclusive with the patchfile parameter.
  • Type: java.util.List
  • Required: No

removeEmptyFiles:

When set to true, the empty files resulting from the patching process are removed. Empty ancestor directories are removed as well.
  • Type: boolean
  • Since: 1.1
  • Required: No
  • Default: false

reverse:

Whether to treat these patches as having reversed source and dest in the patch syntax.
  • Type: boolean
  • Required: No
  • Default: false

skipApplication:

Whether to skip this goal's execution.
  • Type: boolean
  • Required: No
  • Default: false

strictPatching:

Flag that, when set to true, will make sure that all patches included in the patches list must be present and describe the full contents of the patch directory. If strictPatching is set to true, and the patches list has a value that does not correspond to a file in the patch directory, the build will fail. If strictPatching is set to true, and the patch directory contains files not listed in the patches parameter, the build will fail. If set to false, only the patches listed in the patches parameter that have corresponding files will be applied; the rest will be ignored.
  • Type: boolean
  • Required: No
  • Default: false

strip:

The number of directories to be stripped from patch file paths, before applying, starting from the leftmost, or root-est.
  • Type: int
  • Required: No
  • Default: 0

targetDirectory:

The target directory for applying patches. Files in this directory will be modified.
  • Type: java.io.File
  • Required: No
  • Default: ${project.build.sourceDirectory}

useDefaultIgnores:

Whether to exclude default ignored patch items, such as .svn or CVS directories.
  • Type: boolean
  • Required: No
  • Default: true