@Mojo(name="apply",
defaultPhase=PROCESS_SOURCES)
public class ApplyMojo
extends org.apache.maven.plugin.AbstractMojo
| Modifier and Type | Field and Description |
|---|---|
private boolean |
backups
Whether to make backups of the original files before modding them.
|
private boolean |
binary
apply --binary option to patch command line
|
static java.util.List |
DEFAULT_IGNORED_PATCH_PATTERNS |
static java.util.List |
DEFAULT_IGNORED_PATCHES |
private java.io.File |
destFile
The output file which is the original file, plus modifications from the patch.
|
private boolean |
failFast
Flag being
true if the desired behavior is to fail the build on the first failed patch detected. |
private java.util.List |
failurePhrases
List of phrases to watch for in the command output from the patch tool.
|
private java.util.List |
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. |
private boolean |
ignoreWhitespace
Whether to ignore whitespaces when applying the patches.
|
private boolean |
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. |
private boolean |
optimizations
Flag to enable/disable optimization file from being written.
|
private java.io.File |
originalFile
The original file which will be modified by the patch.
|
static java.util.List |
PATCH_FAILURE_WATCH_PHRASES |
private java.io.File |
patchDirectory
The base directory for the file names specified by the parameter
patches. |
protected java.util.List |
patches
The list of patch file names, supplying the order in which patches should be applied.
|
private java.io.File |
patchFile
The single patch file to apply.
|
private java.io.File |
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.
|
private boolean |
removeEmptyFiles
When set to
true, the empty files resulting from the patching process are removed. |
private boolean |
reverse
Whether to treat these patches as having reversed source and dest in the patch syntax.
|
private boolean |
skipApplication
Whether to skip this goal's execution.
|
private boolean |
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. |
private int |
strip
The number of directories to be stripped from patch file paths, before applying, starting from the leftmost, or
root-est.
|
private java.io.File |
targetDirectory
The target directory for applying patches.
|
private boolean |
useDefaultIgnores
Whether to exclude default ignored patch items, such as
.svn or CVS directories. |
| Constructor and Description |
|---|
ApplyMojo() |
| Modifier and Type | Method and Description |
|---|---|
private java.lang.String |
applyPatches(java.util.Map patchesApplied) |
private void |
checkForWatchPhrases(java.lang.String output) |
private void |
checkStrictPatchCompliance(java.util.List foundPatchFiles) |
private org.codehaus.plexus.util.cli.Commandline |
createPatchCommand(java.io.File patchFile)
Add a new Patch task to the Ant calling mechanism.
|
void |
execute()
Apply the patches.
|
private int |
executeCommandLine(org.codehaus.plexus.util.cli.Commandline cli,
org.codehaus.plexus.util.cli.StreamConsumer out,
org.codehaus.plexus.util.cli.StreamConsumer err) |
private java.util.Map |
findPatchesToApply(java.util.List foundPatchFiles,
java.io.File patchSourceDir) |
private void |
writeTrackingFile(java.util.Map patchesApplied) |
public static final java.util.List PATCH_FAILURE_WATCH_PHRASES
public static final java.util.List DEFAULT_IGNORED_PATCHES
public static final java.util.List DEFAULT_IGNORED_PATCH_PATTERNS
@Parameter(defaultValue="true") private boolean useDefaultIgnores
.svn or CVS directories.@Parameter protected java.util.List patches
patchDirectory. This parameter
is mutually exclusive with the patchfile parameter.@Parameter(alias="patch.apply.skip",
defaultValue="false")
private boolean skipApplication
@Parameter(defaultValue="true") private boolean optimizations
mvn clean" must be executed before the next
build, to remove the tracking file.@Parameter(defaultValue="${project.build.directory}/optimization-files/patches-applied.txt")
private java.io.File patchTrackingFile
@Parameter(alias="patchTargetDir",
defaultValue="${project.build.sourceDirectory}")
private java.io.File targetDirectory
@Parameter(defaultValue="true") private boolean failFast
true if the desired behavior is to fail the build on the first failed patch detected.@Parameter(defaultValue="false") private boolean naturalOrderProcessing
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.@Parameter private java.util.List ignoredPatches
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.@Parameter(defaultValue="false") private boolean strictPatching
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.@Parameter(defaultValue="0") private int strip
@Parameter(defaultValue="true") private boolean ignoreWhitespace
@Parameter(defaultValue="false") private boolean reverse
@Parameter(defaultValue="false") private boolean backups
@Parameter private java.util.List failurePhrases
fail,
skip and reject are used.@Parameter private java.io.File originalFile
@Parameter private java.io.File destFile
@Parameter private java.io.File patchFile
patches parameter.@Parameter(defaultValue="src/main/patches") private java.io.File patchDirectory
patches.@Parameter(defaultValue="false") private boolean removeEmptyFiles
true, the empty files resulting from the patching process are removed. Empty ancestor
directories are removed as well.@Parameter(defaultValue="false") private boolean binary
public void execute()
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureExceptionprivate java.util.Map findPatchesToApply(java.util.List foundPatchFiles,
java.io.File patchSourceDir)
throws org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoFailureExceptionprivate void checkStrictPatchCompliance(java.util.List foundPatchFiles)
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate java.lang.String applyPatches(java.util.Map patchesApplied)
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate int executeCommandLine(org.codehaus.plexus.util.cli.Commandline cli,
org.codehaus.plexus.util.cli.StreamConsumer out,
org.codehaus.plexus.util.cli.StreamConsumer err)
throws org.codehaus.plexus.util.cli.CommandLineException
org.codehaus.plexus.util.cli.CommandLineExceptionprivate void writeTrackingFile(java.util.Map patchesApplied)
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate void checkForWatchPhrases(java.lang.String output)
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionprivate org.codehaus.plexus.util.cli.Commandline createPatchCommand(java.io.File patchFile)