ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r668718 - /ant/core/trunk/src/main/org/apache/tools/ant/util/ResourceUtils.java
Date Tue, 17 Jun 2008 15:57:21 GMT
Author: mbenson
Date: Tue Jun 17 08:57:20 2008
New Revision: 668718

URL: http://svn.apache.org/viewvc?rev=668718&view=rev
Log:
helper method

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/util/ResourceUtils.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/ResourceUtils.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/ResourceUtils.java?rev=668718&r1=668717&r2=668718&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/ResourceUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/ResourceUtils.java Tue Jun 17 08:57:20
2008
@@ -39,6 +39,8 @@
 import org.apache.tools.ant.types.ResourceFactory;
 import org.apache.tools.ant.types.ResourceCollection;
 import org.apache.tools.ant.types.FilterSetCollection;
+import org.apache.tools.ant.types.resources.FileProvider;
+import org.apache.tools.ant.types.resources.FileResource;
 import org.apache.tools.ant.types.resources.Union;
 import org.apache.tools.ant.types.resources.Restrict;
 import org.apache.tools.ant.types.resources.Resources;
@@ -476,6 +478,21 @@
     }
 
     /**
+     * Convenience method to turn any fileProvider into a basic FileResource with the
+     * file's immediate parent as the basedir, for tasks that need one.
+     * @param fileProvider input
+     * @return fileProvider if it is a FileResource instance, or a new FileResource with
fileProvider's file.
+     */
+    public static FileResource asFileResource(FileProvider fileProvider) {
+        if (fileProvider instanceof FileResource || fileProvider == null) {
+            return (FileResource) fileProvider;
+        }
+        FileResource result = new FileResource(fileProvider.getFile());
+        result.setProject(Project.getProject(fileProvider));
+        return result;
+    }
+
+    /**
      * Binary compares the contents of two Resources.
      * <p>
      * simple but sub-optimal comparision algorithm. written for working



Mime
View raw message