bodewig     2003/03/13 08:14:51

  Modified:    src/main/org/apache/tools/ant/taskdefs Ear.java War.java
               src/main/org/apache/tools/ant/util FileUtils.java
  Log:
  This is supposed to fix bug 17871.
  
  The patch looks innocent enough for me to merge it into the 1.5 branch
  right away, but I cannot really verify it fixes the bug because of my
  persistent (and self-imposed) lack of a Windows system.
  
  Revision  Changes    Path
  1.23      +3 -1      ant/src/main/org/apache/tools/ant/taskdefs/Ear.java
  
  Index: Ear.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Ear.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- Ear.java  7 Mar 2003 11:23:01 -0000       1.22
  +++ Ear.java  13 Mar 2003 16:14:51 -0000      1.23
  @@ -58,6 +58,7 @@
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.types.ZipFileSet;
  +import org.apache.tools.ant.util.FileUtils;
   import org.apache.tools.zip.ZipOutputStream;
   
   /**
  @@ -74,6 +75,7 @@
   
       private File deploymentDescriptor;
       private boolean descriptorAdded;
  +    private static final FileUtils fu = FileUtils.newFileUtils();
   
       /**
        * Create an Ear task.
  @@ -146,7 +148,7 @@
           // <fileset> element.
           if (vPath.equalsIgnoreCase("META-INF/application.xml"))  {
               if (deploymentDescriptor == null 
  -                || !deploymentDescriptor.equals(file) 
  +                || !fu.fileNameEquals(deploymentDescriptor, file)
                   || descriptorAdded) {
                   log("Warning: selected " + archiveType
                       + " files include a META-INF/application.xml which will"
  
  
  
  1.32      +4 -1      ant/src/main/org/apache/tools/ant/taskdefs/War.java
  
  Index: War.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/War.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- War.java  7 Mar 2003 11:23:02 -0000       1.31
  +++ War.java  13 Mar 2003 16:14:51 -0000      1.32
  @@ -59,6 +59,7 @@
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.types.ZipFileSet;
  +import org.apache.tools.ant.util.FileUtils;
   import org.apache.tools.zip.ZipOutputStream;
   
   
  @@ -91,6 +92,8 @@
        */
       private boolean descriptorAdded;
   
  +    private static final FileUtils fu = FileUtils.newFileUtils();
  +
       public War() {
           super();
           archiveType = "war";
  @@ -180,7 +183,7 @@
           // by the "webxml" attribute and in a <fileset> element.
           if (vPath.equalsIgnoreCase("WEB-INF/web.xml"))  {
               if (deploymentDescriptor == null
  -                || !deploymentDescriptor.equals(file)
  +                || !fu.fileNameEquals(deploymentDescriptor, file)
                   || descriptorAdded) {
                   log("Warning: selected " + archiveType
                       + " files include a WEB-INF/web.xml which will be 
ignored "
  
  
  
  1.38      +16 -2     ant/src/main/org/apache/tools/ant/util/FileUtils.java
  
  Index: FileUtils.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/FileUtils.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- FileUtils.java    7 Mar 2003 11:23:08 -0000       1.37
  +++ FileUtils.java    13 Mar 2003 16:14:51 -0000      1.38
  @@ -734,7 +734,7 @@
               return false;
           }
   
  -        if (f1.equals(f2)) {
  +        if (fileNameEquals(f1, f2)) {
               // same filename => true
               return true;
           }
  @@ -999,6 +999,20 @@
               // relative path
           }
           return path;
  +    }
  +
  +    /**
  +     * Compares two filenames.
  +     *
  +     * <p>Unlike java.io.File#equals this method will try to compare
  +     * the absolute paths and &quot;normalize&quot; the filenames
  +     * before comparing them.</p>
  +     *
  +     * @since Ant 1.5.2
  +     */
  +    public boolean fileNameEquals(File f1, File f2) {
  +        return normalize(f1.getAbsolutePath())
  +            .equals(normalize(f2.getAbsolutePath()));
       }
   
   }
  
  
  

Reply via email to