This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-patch-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 76150b6  Update dependencies (#3)
76150b6 is described below

commit 76150b6bd4bb7224934c0ae3f75b289bb7e22390
Author: Elliotte Rusty Harold <elh...@users.noreply.github.com>
AuthorDate: Sat Dec 7 12:53:53 2024 +0000

    Update dependencies (#3)
---
 pom.xml                                            |  31 +-
 .../org/apache/maven/plugin/patch/ApplyMojo.java   | 453 +++++++++------------
 2 files changed, 208 insertions(+), 276 deletions(-)

diff --git a/pom.xml b/pom.xml
index dfdf120..b3f6004 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,4 @@
-<?xml version='1.0' encoding='UTF-8'?>
-
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
@@ -18,15 +17,14 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 -->
-
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-plugins</artifactId>
-    <version>34</version>
-    <relativePath/>
+    <version>43</version>
+    <relativePath />
   </parent>
 
   <artifactId>maven-patch-plugin</artifactId>
@@ -36,21 +34,21 @@ under the License.
   <name>Apache Maven Patch Plugin</name>
   <description>The Patch Plugin is used to apply patches to source 
files.</description>
 
-  <prerequisites>
-    <maven>${mavenVersion}</maven>
-  </prerequisites>
-
   <contributors>
     <contributor>
       <name>Heath Nielson</name>
     </contributor>
   </contributors>
 
+  <prerequisites>
+    <maven>${mavenVersion}</maven>
+  </prerequisites>
+
   <scm>
     
<connection>scm:git:https://gitbox.apache.org/repos/asf/maven-patch-plugin.git</connection>
     
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-patch-plugin.git</developerConnection>
-    
<url>https://github.com/apache/maven-patch-plugin/tree/${project.scm.tag}</url>
     <tag>HEAD</tag>
+    
<url>https://github.com/apache/maven-patch-plugin/tree/${project.scm.tag}</url>
   </scm>
   <issueManagement>
     <system>JIRA</system>
@@ -68,7 +66,7 @@ under the License.
   </distributionManagement>
 
   <properties>
-    <mavenVersion>2.2.1</mavenVersion>
+    <mavenVersion>3.6.3</mavenVersion>
     
<project.build.outputTimestamp>2020-04-07T21:04:00Z</project.build.outputTimestamp>
   </properties>
 
@@ -78,6 +76,7 @@ under the License.
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
       <version>${mavenVersion}</version>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.plugin-tools</groupId>
@@ -89,15 +88,7 @@ under the License.
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>3.0.24</version>
-    </dependency>
-
-    <!-- Others -->
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.2</version>
-      <scope>test</scope>
+      <version>3.5.1</version>
     </dependency>
   </dependencies>
 
diff --git a/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java 
b/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java
index d253a79..3a14e2d 100644
--- a/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java
+++ b/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.maven.plugin.patch;
 
 /*
@@ -19,6 +37,19 @@ package org.apache.maven.plugin.patch;
  * under the License.
  */
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -33,26 +64,11 @@ import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
 import org.codehaus.plexus.util.cli.StreamConsumer;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
 /**
  * Apply one or more patches to project sources.
  */
-@Mojo( name = "apply", defaultPhase = LifecyclePhase.PROCESS_SOURCES )
-public class ApplyMojo
-    extends AbstractMojo
-{
+@Mojo(name = "apply", defaultPhase = LifecyclePhase.PROCESS_SOURCES)
+public class ApplyMojo extends AbstractMojo {
 
     public static final List PATCH_FAILURE_WATCH_PHRASES;
 
@@ -60,27 +76,26 @@ public class ApplyMojo
 
     public static final List DEFAULT_IGNORED_PATCH_PATTERNS;
 
-    static
-    {
+    static {
         List watches = new ArrayList();
 
-        watches.add( "fail" );
-        watches.add( "skip" );
-        watches.add( "reject" );
+        watches.add("fail");
+        watches.add("skip");
+        watches.add("reject");
 
         PATCH_FAILURE_WATCH_PHRASES = watches;
 
         List ignored = new ArrayList();
 
-        ignored.add( ".svn" );
-        ignored.add( "CVS" );
+        ignored.add(".svn");
+        ignored.add("CVS");
 
         DEFAULT_IGNORED_PATCHES = ignored;
 
         List ignoredPatterns = new ArrayList();
 
-        ignoredPatterns.add( ".svn/**" );
-        ignoredPatterns.add( "CVS/**" );
+        ignoredPatterns.add(".svn/**");
+        ignoredPatterns.add("CVS/**");
 
         DEFAULT_IGNORED_PATCH_PATTERNS = ignoredPatterns;
     }
@@ -88,7 +103,7 @@ public class ApplyMojo
     /**
      * Whether to exclude default ignored patch items, such as 
<code>.svn</code> or <code>CVS</code> directories.
      */
-    @Parameter( defaultValue = "true" )
+    @Parameter(defaultValue = "true")
     private boolean useDefaultIgnores;
 
     /**
@@ -102,7 +117,7 @@ public class ApplyMojo
     /**
      * Whether to skip this goal's execution.
      */
-    @Parameter( alias = "patch.apply.skip", defaultValue = "false" )
+    @Parameter(alias = "patch.apply.skip", defaultValue = "false")
     private boolean skipApplication;
 
     /**
@@ -113,7 +128,7 @@ public class ApplyMojo
      * list of patches changes and this flag is enabled, a "<code>mvn 
clean</code>" must be executed before the next
      * build, to remove the tracking file.
      */
-    @Parameter( defaultValue = "true" )
+    @Parameter(defaultValue = "true")
     private boolean optimizations;
 
     /**
@@ -122,26 +137,26 @@ public class ApplyMojo
      * (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.
      */
-    @Parameter( defaultValue = 
"${project.build.directory}/optimization-files/patches-applied.txt" )
+    @Parameter(defaultValue = 
"${project.build.directory}/optimization-files/patches-applied.txt")
     private File patchTrackingFile;
 
     /**
      * The target directory for applying patches. Files in this directory will 
be modified.
      */
-    @Parameter( alias = "patchTargetDir", defaultValue = 
"${project.build.sourceDirectory}" )
+    @Parameter(alias = "patchTargetDir", defaultValue = 
"${project.build.sourceDirectory}")
     private File targetDirectory;
 
     /**
      * Flag being <code>true</code> if the desired behavior is to fail the 
build on the first failed patch detected.
      */
-    @Parameter( defaultValue = "true" )
+    @Parameter(defaultValue = "true")
     private boolean failFast;
 
     /**
      * Setting natural order processing to <code>true</code> 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( defaultValue = "false" )
+    @Parameter(defaultValue = "false")
     private boolean naturalOrderProcessing;
 
     /**
@@ -160,32 +175,32 @@ public class ApplyMojo
      * set to <code>false</code>, only the patches listed in the 
<code>patches</code> parameter that have
      * corresponding files will be applied; the rest will be ignored.
      */
-    @Parameter( defaultValue = "false" )
+    @Parameter(defaultValue = "false")
     private boolean strictPatching;
 
     /**
      * The number of directories to be stripped from patch file paths, before 
applying, starting from the leftmost, or
      * root-est.
      */
-    @Parameter( defaultValue = "0" )
+    @Parameter(defaultValue = "0")
     private int strip;
 
     /**
      * Whether to ignore whitespaces when applying the patches.
      */
-    @Parameter( defaultValue = "true" )
+    @Parameter(defaultValue = "true")
     private boolean ignoreWhitespace;
 
     /**
      * Whether to treat these patches as having reversed source and dest in 
the patch syntax.
      */
-    @Parameter( defaultValue = "false" )
+    @Parameter(defaultValue = "false")
     private boolean reverse;
 
     /**
      * Whether to make backups of the original files before modding them.
      */
-    @Parameter( defaultValue = "false" )
+    @Parameter(defaultValue = "false")
     private boolean backups;
 
     /**
@@ -219,7 +234,7 @@ public class ApplyMojo
     /**
      * The base directory for the file names specified by the parameter 
<code>patches</code>.
      */
-    @Parameter( defaultValue = "src/main/patches" )
+    @Parameter(defaultValue = "src/main/patches")
     private File patchDirectory;
 
     /**
@@ -228,14 +243,14 @@ public class ApplyMojo
      *
      * @since 1.1
      */
-    @Parameter( defaultValue = "false" )
+    @Parameter(defaultValue = "false")
     private boolean removeEmptyFiles;
 
     /**
      * apply --binary option to patch command line
      * @since 1.2
      */
-    @Parameter( defaultValue = "false" )
+    @Parameter(defaultValue = "false")
     private boolean binary;
 
     /**
@@ -252,22 +267,18 @@ public class ApplyMojo
      * Apply the patches. Give preference to patchFile over 
patchSourceDir/patches, and preference to originalFile over
      * workDir.
      */
-    public void execute()
-        throws MojoExecutionException, MojoFailureException
-    {
-        boolean patchDirEnabled = ( ( patches != null ) && !patches.isEmpty() 
) || naturalOrderProcessing;
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        boolean patchDirEnabled = ((patches != null) && !patches.isEmpty()) || 
naturalOrderProcessing;
         boolean patchFileEnabled = patchFile != null;
 
         // if patches is null or empty, and naturalOrderProcessing is not true 
then disable patching
-        if ( !patchFileEnabled && !patchDirEnabled )
-        {
-            getLog().info( "Patching is disabled for this project." );
+        if (!patchFileEnabled && !patchDirEnabled) {
+            getLog().info("Patching is disabled for this project.");
             return;
         }
 
-        if ( skipApplication )
-        {
-            getLog().info( "Skipping patch file application (per 
configuration)." );
+        if (skipApplication) {
+            getLog().info("Skipping patch file application (per 
configuration).");
             return;
         }
 
@@ -275,102 +286,81 @@ public class ApplyMojo
 
         Map patchesToApply;
 
-        try
-        {
-            if ( patchFileEnabled )
-            {
-                patchesToApply = Collections.singletonMap( 
patchFile.getName(), createPatchCommand( patchFile ) );
-            }
-            else
-            {
-                if ( !patchDirectory.isDirectory() )
-                {
-                    throw new FileNotFoundException( "The base directory for 
patch files does not exist: "
-                        + patchDirectory );
+        try {
+            if (patchFileEnabled) {
+                patchesToApply = Collections.singletonMap(patchFile.getName(), 
createPatchCommand(patchFile));
+            } else {
+                if (!patchDirectory.isDirectory()) {
+                    throw new FileNotFoundException(
+                            "The base directory for patch files does not 
exist: " + patchDirectory);
                 }
 
                 String excludePatterns = null;
-                if ( excludes != null )
-                {
-                    excludePatterns = StringUtils.join( excludes.iterator(), 
"," );
-                    getLog().info( "Exclude pattern: " + excludePatterns );
+                if (excludes != null) {
+                    excludePatterns = StringUtils.join(excludes.iterator(), 
",");
+                    getLog().info("Exclude pattern: " + excludePatterns);
                 }
 
-                List foundPatchFiles = FileUtils.getFileNames( patchDirectory, 
"*", excludePatterns, false );
+                List foundPatchFiles = FileUtils.getFileNames(patchDirectory, 
"*", excludePatterns, false);
 
-                patchesToApply = findPatchesToApply( foundPatchFiles, 
patchDirectory );
+                patchesToApply = findPatchesToApply(foundPatchFiles, 
patchDirectory);
 
-                checkStrictPatchCompliance( foundPatchFiles );
+                checkStrictPatchCompliance(foundPatchFiles);
             }
 
-            String output = applyPatches( patchesToApply );
+            String output = applyPatches(patchesToApply);
 
-            checkForWatchPhrases( output );
+            checkForWatchPhrases(output);
 
-            writeTrackingFile( patchesToApply );
-        }
-        catch ( IOException ioe )
-        {
-            throw new MojoExecutionException( "Unable to obtain list of patch 
files", ioe );
+            writeTrackingFile(patchesToApply);
+        } catch (IOException ioe) {
+            throw new MojoExecutionException("Unable to obtain list of patch 
files", ioe);
         }
     }
 
-    private Map findPatchesToApply( List foundPatchFiles, File patchSourceDir )
-        throws MojoFailureException
-    {
+    private Map findPatchesToApply(List foundPatchFiles, File patchSourceDir) 
throws MojoFailureException {
         Map patchesApplied = new LinkedHashMap();
 
-        if ( naturalOrderProcessing )
-        {
-            patches = new ArrayList( foundPatchFiles );
-            Collections.sort( patches );
+        if (naturalOrderProcessing) {
+            patches = new ArrayList(foundPatchFiles);
+            Collections.sort(patches);
         }
 
         String alreadyAppliedPatches = "";
 
-        try
-        {
-            if ( optimizations && patchTrackingFile.exists() )
-            {
-                alreadyAppliedPatches = FileUtils.fileRead( patchTrackingFile 
);
+        try {
+            if (optimizations && patchTrackingFile.exists()) {
+                alreadyAppliedPatches = FileUtils.fileRead(patchTrackingFile);
             }
-        }
-        catch ( IOException ioe )
-        {
-            throw new MojoFailureException( "unable to read patch tracking 
file: " + ioe.getMessage() );
+        } catch (IOException ioe) {
+            throw new MojoFailureException("unable to read patch tracking 
file: " + ioe.getMessage());
         }
 
-        for ( Object patche : patches )
-        {
+        for (Object patche : patches) {
             String patch = (String) patche;
 
-            if ( !alreadyAppliedPatches.contains( patch ) )
-            {
-                File patchFile = new File( patchSourceDir, patch );
-
-                getLog().debug( "Looking for patch: " + patch + " in: " + 
patchFile );
-
-                if ( !patchFile.exists() )
-                {
-                    if ( strictPatching )
-                    {
-                        throw new MojoFailureException( this, "Patch operation 
cannot proceed.",
-                                                        "Cannot find specified 
patch: \'" + patch
-                                                            + "\' in 
patch-source directory: \'" + patchSourceDir
-                                                            + "\'.\n\nEither 
fix this error, "
-                                                            + "or relax 
strictPatching." );
-                    }
-                    else
-                    {
-                        getLog().info( "Skipping patch: " + patch + " listed 
in the parameter \"patches\"; "
-                                           + "it is missing." );
+            if (!alreadyAppliedPatches.contains(patch)) {
+                File patchFile = new File(patchSourceDir, patch);
+
+                getLog().debug("Looking for patch: " + patch + " in: " + 
patchFile);
+
+                if (!patchFile.exists()) {
+                    if (strictPatching) {
+                        throw new MojoFailureException(
+                                this,
+                                "Patch operation cannot proceed.",
+                                "Cannot find specified patch: \'" + patch
+                                        + "\' in patch-source directory: \'" + 
patchSourceDir
+                                        + "\'.\n\nEither fix this error, "
+                                        + "or relax strictPatching.");
+                    } else {
+                        getLog().info("Skipping patch: " + patch + " listed in 
the parameter \"patches\"; "
+                                + "it is missing.");
                     }
-                }
-                else
-                {
-                    foundPatchFiles.remove( patch );
+                } else {
+                    foundPatchFiles.remove(patch);
 
-                    patchesApplied.put( patch, createPatchCommand( patchFile ) 
);
+                    patchesApplied.put(patch, createPatchCommand(patchFile));
                 }
             }
         }
@@ -378,188 +368,148 @@ public class ApplyMojo
         return patchesApplied;
     }
 
-    private void checkStrictPatchCompliance( List foundPatchFiles )
-        throws MojoExecutionException
-    {
-        if ( strictPatching )
-        {
+    private void checkStrictPatchCompliance(List foundPatchFiles) throws 
MojoExecutionException {
+        if (strictPatching) {
             List ignored = new ArrayList();
 
-            if ( ignoredPatches != null )
-            {
-                ignored.addAll( ignoredPatches );
+            if (ignoredPatches != null) {
+                ignored.addAll(ignoredPatches);
             }
 
-            if ( useDefaultIgnores )
-            {
-                ignored.addAll( DEFAULT_IGNORED_PATCHES );
+            if (useDefaultIgnores) {
+                ignored.addAll(DEFAULT_IGNORED_PATCHES);
             }
 
-            List limbo = new ArrayList( foundPatchFiles );
+            List limbo = new ArrayList(foundPatchFiles);
 
-            for ( Object anIgnored : ignored )
-            {
+            for (Object anIgnored : ignored) {
                 String ignoredFile = (String) anIgnored;
 
-                limbo.remove( ignoredFile );
+                limbo.remove(ignoredFile);
             }
 
-            if ( !limbo.isEmpty() )
-            {
+            if (!limbo.isEmpty()) {
                 StringBuilder extraFileBuffer = new StringBuilder();
 
-                extraFileBuffer.append( "Found " ).append( limbo.size() 
).append( " unlisted patch files:" );
+                extraFileBuffer.append("Found ").append(limbo.size()).append(" 
unlisted patch files:");
 
-                for ( Object foundPatchFile : foundPatchFiles )
-                {
+                for (Object foundPatchFile : foundPatchFiles) {
                     String patch = (String) foundPatchFile;
 
-                    extraFileBuffer.append( "\n  \'" ).append( patch ).append( 
'\'' );
+                    extraFileBuffer.append("\n  
\'").append(patch).append('\'');
                 }
 
-                extraFileBuffer.append( "\n\nEither remove these files, "
-                    + "add them to the patches configuration list, " + "or 
relax strictPatching." );
+                extraFileBuffer.append("\n\nEither remove these files, "
+                        + "add them to the patches configuration list, " + "or 
relax strictPatching.");
 
-                throw new MojoExecutionException( extraFileBuffer.toString() );
+                throw new MojoExecutionException(extraFileBuffer.toString());
             }
         }
     }
 
-    private String applyPatches( Map patchesApplied )
-        throws MojoExecutionException
-    {
+    private String applyPatches(Map patchesApplied) throws 
MojoExecutionException {
         final StringWriter outputWriter = new StringWriter();
 
-        StreamConsumer consumer = new StreamConsumer()
-        {
-            public void consumeLine( String line )
-            {
-                if ( getLog().isDebugEnabled() )
-                {
-                    getLog().debug( line );
+        StreamConsumer consumer = new StreamConsumer() {
+            public void consumeLine(String line) {
+                if (getLog().isDebugEnabled()) {
+                    getLog().debug(line);
                 }
 
-                outputWriter.write( line + "\n" );
+                outputWriter.write(line + "\n");
             }
         };
 
         // used if failFast is false
         List failedPatches = new ArrayList();
 
-        for ( Object o : patchesApplied.entrySet() )
-        {
+        for (Object o : patchesApplied.entrySet()) {
             Entry entry = (Entry) o;
             String patchName = (String) entry.getKey();
             Commandline cli = (Commandline) entry.getValue();
 
-            try
-            {
-                getLog().info( "Applying patch: " + patchName );
+            try {
+                getLog().info("Applying patch: " + patchName);
 
-                int result = executeCommandLine( cli, consumer, consumer );
+                int result = executeCommandLine(cli, consumer, consumer);
 
-                if ( result != 0 )
-                {
-                    if ( failFast )
-                    {
-                        throw new MojoExecutionException( "Patch command 
failed with exit code " + result + " for "
-                            + patchName + ". Please see console and debug 
output for more information." );
-                    }
-                    else
-                    {
-                        failedPatches.add( patchName );
+                if (result != 0) {
+                    if (failFast) {
+                        throw new MojoExecutionException("Patch command failed 
with exit code " + result + " for "
+                                + patchName + ". Please see console and debug 
output for more information.");
+                    } else {
+                        failedPatches.add(patchName);
                     }
                 }
-            }
-            catch ( CommandLineException e )
-            {
-                throw new MojoExecutionException( "Failed to apply patch: " + 
patchName
-                    + ". See debug output for more information.", e );
+            } catch (CommandLineException e) {
+                throw new MojoExecutionException(
+                        "Failed to apply patch: " + patchName + ". See debug 
output for more information.", e);
             }
         }
 
-        if ( !failedPatches.isEmpty() )
-        {
-            getLog().error( "Failed applying one or more patches:" );
-            for ( Object failedPatche : failedPatches )
-            {
-                getLog().error( "* " + failedPatche );
+        if (!failedPatches.isEmpty()) {
+            getLog().error("Failed applying one or more patches:");
+            for (Object failedPatche : failedPatches) {
+                getLog().error("* " + failedPatche);
             }
-            throw new MojoExecutionException( "Patch command failed for one or 
more patches."
-                + " Please see console and debug output for more information." 
);
+            throw new MojoExecutionException("Patch command failed for one or 
more patches."
+                    + " Please see console and debug output for more 
information.");
         }
 
         return outputWriter.toString();
     }
 
-    private int executeCommandLine( Commandline cli, StreamConsumer out, 
StreamConsumer err )
-        throws CommandLineException
-    {
-        if ( getLog().isDebugEnabled() )
-        {
-            getLog().debug( "Executing: " + cli );
+    private int executeCommandLine(Commandline cli, StreamConsumer out, 
StreamConsumer err)
+            throws CommandLineException {
+        if (getLog().isDebugEnabled()) {
+            getLog().debug("Executing: " + cli);
         }
 
-        int result = CommandLineUtils.executeCommandLine( cli, out, err );
+        int result = CommandLineUtils.executeCommandLine(cli, out, err);
 
-        if ( getLog().isDebugEnabled() )
-        {
-            getLog().debug( "Exit code: " + result );
+        if (getLog().isDebugEnabled()) {
+            getLog().debug("Exit code: " + result);
         }
 
         return result;
     }
 
-    private void writeTrackingFile( Map patchesApplied )
-        throws MojoExecutionException
-    {
+    private void writeTrackingFile(Map patchesApplied) throws 
MojoExecutionException {
         FileWriter writer = null;
-        try
-        {
+        try {
             boolean appending = patchTrackingFile.exists();
 
-            writer = new FileWriter( patchTrackingFile, appending );
+            writer = new FileWriter(patchTrackingFile, appending);
 
-            for ( Iterator it = patchesApplied.keySet().iterator(); 
it.hasNext(); )
-            {
-                if ( appending )
-                {
-                    writer.write( System.getProperty( "line.separator" ) );
+            for (Iterator it = patchesApplied.keySet().iterator(); 
it.hasNext(); ) {
+                if (appending) {
+                    writer.write(System.getProperty("line.separator"));
                 }
 
                 String patch = (String) it.next();
-                writer.write( patch );
+                writer.write(patch);
 
-                if ( it.hasNext() )
-                {
-                    writer.write( System.getProperty( "line.separator" ) );
+                if (it.hasNext()) {
+                    writer.write(System.getProperty("line.separator"));
                 }
             }
 
             writer.close();
             writer = null;
-        }
-        catch ( IOException e )
-        {
-            throw new MojoExecutionException( "Failed to write patch-tracking 
file: " + patchTrackingFile, e );
-        }
-        finally
-        {
-            IOUtil.close( writer );
+        } catch (IOException e) {
+            throw new MojoExecutionException("Failed to write patch-tracking 
file: " + patchTrackingFile, e);
+        } finally {
+            IOUtil.close(writer);
         }
     }
 
-    private void checkForWatchPhrases( String output )
-        throws MojoExecutionException
-    {
-        for ( Object failurePhrase : failurePhrases )
-        {
+    private void checkForWatchPhrases(String output) throws 
MojoExecutionException {
+        for (Object failurePhrase : failurePhrases) {
             String phrase = (String) failurePhrase;
 
-            if ( output.contains( phrase ) )
-            {
-                throw new MojoExecutionException( "Failed to apply patches 
(detected watch-phrase: \'" + phrase
-                    + "\' in output). " + "If this is in error, configure the 
patchFailureWatchPhrases parameter." );
+            if (output.contains(phrase)) {
+                throw new MojoExecutionException("Failed to apply patches 
(detected watch-phrase: \'" + phrase
+                        + "\' in output). " + "If this is in error, configure 
the patchFailureWatchPhrases parameter.");
             }
         }
     }
@@ -568,56 +518,47 @@ public class ApplyMojo
      * Add a new Patch task to the Ant calling mechanism. Give preference to 
originalFile/destFile, then workDir, and
      * finally ${basedir}.
      */
-    private Commandline createPatchCommand( File patchFile )
-    {
+    private Commandline createPatchCommand(File patchFile) {
         Commandline cli = new Commandline();
 
-        cli.setExecutable( "patch" );
+        cli.setExecutable("patch");
 
-        cli.setWorkingDirectory( targetDirectory.getAbsolutePath() );
+        cli.setWorkingDirectory(targetDirectory.getAbsolutePath());
 
-        cli.createArg().setValue( "-p" + strip );
+        cli.createArg().setValue("-p" + strip);
 
-        if ( binary )
-        {
-            cli.createArg().setValue( "--binary" );
+        if (binary) {
+            cli.createArg().setValue("--binary");
         }
 
-        if ( ignoreWhitespace )
-        {
-            cli.createArg().setValue( "-l" );
+        if (ignoreWhitespace) {
+            cli.createArg().setValue("-l");
         }
 
-        if ( reverse )
-        {
-            cli.createArg().setValue( "-R" );
+        if (reverse) {
+            cli.createArg().setValue("-R");
         }
 
-        if ( backups )
-        {
-            cli.createArg().setValue( "-b" );
+        if (backups) {
+            cli.createArg().setValue("-b");
         }
 
-        if ( removeEmptyFiles )
-        {
-            cli.createArg().setValue( "-E" );
+        if (removeEmptyFiles) {
+            cli.createArg().setValue("-E");
         }
 
-        cli.createArg().setValue( "-i" );
-        cli.createArg().setFile( patchFile );
+        cli.createArg().setValue("-i");
+        cli.createArg().setFile(patchFile);
 
-        if ( destFile != null )
-        {
-            cli.createArg().setValue( "-o" );
-            cli.createArg().setFile( destFile );
+        if (destFile != null) {
+            cli.createArg().setValue("-o");
+            cli.createArg().setFile(destFile);
         }
 
-        if ( originalFile != null )
-        {
-            cli.createArg().setFile( originalFile );
+        if (originalFile != null) {
+            cli.createArg().setFile(originalFile);
         }
 
         return cli;
     }
-
 }

Reply via email to