Author: maartenc
Date: Fri Oct 17 14:55:13 2008
New Revision: 705768

URL: http://svn.apache.org/viewvc?rev=705768&view=rev
Log:
FIX: cachefileset produces an empty fileset when the cache refers to libs in 
directories that only have the root directory in common (IVY-948) (thanks to 
Chris Wood)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=705768&r1=705767&r2=705768&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Fri Oct 17 14:55:13 2008
@@ -75,6 +75,7 @@
        James P. White
        Tom Widmer
        John Williams
+    Chris Wood
        Patrick Woodworth
        Jaroslaw Wypychowski
        
@@ -104,6 +105,7 @@
 - FIX: Can't use latest.release for pom dependencies (IVY-936)
 - FIX: Unable to resolve snapshot versions depending on xml elements order 
(IVY-940)
 - FIX: pre-resolve-dependency event doesn't export branch information 
(IVY-941) (thanks to Jaroslaw Wypychowski)
+- FIX: cachefileset produces an empty fileset when the cache refers to libs in 
directories that only have the root directory in common (IVY-948) (thanks to 
Chris Wood)
 
    2.0.0-rc1
 =====================================

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java?rev=705768&r1=705767&r2=705768&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java 
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java Fri Oct 
17 14:55:13 2008
@@ -78,7 +78,7 @@
                 for (Iterator iter = paths.iterator(); iter.hasNext();) {
                     ArtifactDownloadReport a = (ArtifactDownloadReport) 
iter.next();
                     if (a.getLocalFile() != null) {
-                        NameEntry ne = fileset.createInclude();
+                        NameEntry ne = fileset. createInclude();
                         ne.setName(getPath(base, a.getLocalFile()));
                     }
                 }
@@ -93,10 +93,20 @@
      * 
      * @param base the parent directory to which the file must be evaluated.
      * @param file the file for which the path should be returned
-     * @returnthe path of the file relative to the given base directory.
+     * @return the path of the file relative to the given base directory.
      */
     private String getPath(File base, File file) {
-        return 
file.getAbsolutePath().substring(base.getAbsolutePath().length() + 1);
+        String absoluteBasePath = base.getAbsolutePath();
+        
+        int beginIndex = absoluteBasePath.length();
+        
+        // checks if the basePath ends with the file separator (which can for 
instance
+        // happen if the basePath is the root on unix)
+        if (!absoluteBasePath.endsWith(File.separator)) {
+            beginIndex++; // skip the seperator char as well
+        }
+        
+        return file.getAbsolutePath().substring(beginIndex);
     }
 
     /**


Reply via email to