lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r786610 - in /lucene/java/trunk: CHANGES.txt contrib/ant/example.xml contrib/ant/src/java/org/apache/lucene/ant/IndexTask.java contrib/ant/src/test/org/apache/lucene/ant/IndexTaskTest.java
Date Fri, 19 Jun 2009 18:24:19 GMT
Author: ehatcher
Date: Fri Jun 19 18:24:19 2009
New Revision: 786610

URL: http://svn.apache.org/viewvc?rev=786610&view=rev
Log:
LUCENE-1405: Added support for Ant resource collections in contrib/ant <index> task.

Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/contrib/ant/example.xml
    lucene/java/trunk/contrib/ant/src/java/org/apache/lucene/ant/IndexTask.java
    lucene/java/trunk/contrib/ant/src/test/org/apache/lucene/ant/IndexTaskTest.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=786610&r1=786609&r2=786610&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Fri Jun 19 18:24:19 2009
@@ -421,6 +421,9 @@
     structure of terms in the index that can be created by indexing
     using the new NumericTokenStream class.  (Uwe Schindler,
     Yonik Seeley, Mike McCandless)
+
+28. LUCENE-1405: Added support for Ant resource collections in contrib/ant
+    <index> task.  (Przemyslaw Sztoch via Erik Hatcher)
     
 Optimizations
 

Modified: lucene/java/trunk/contrib/ant/example.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/ant/example.xml?rev=786610&r1=786609&r2=786610&view=diff
==============================================================================
--- lucene/java/trunk/contrib/ant/example.xml (original)
+++ lucene/java/trunk/contrib/ant/example.xml Fri Jun 19 18:24:19 2009
@@ -1,4 +1,8 @@
 <?xml version="1.0"?>
+<!--
+To use this example from a source checkout:
+   ant -f example.xml -lib ../../build/contrib/ant/ -lib ../../build/ -lib lib
+-->
 <project name="ant-example" default="index">
 
   <description>

Modified: lucene/java/trunk/contrib/ant/src/java/org/apache/lucene/ant/IndexTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/ant/src/java/org/apache/lucene/ant/IndexTask.java?rev=786610&r1=786609&r2=786610&view=diff
==============================================================================
--- lucene/java/trunk/contrib/ant/src/java/org/apache/lucene/ant/IndexTask.java (original)
+++ lucene/java/trunk/contrib/ant/src/java/org/apache/lucene/ant/IndexTask.java Fri Jun 19
18:24:19 2009
@@ -38,15 +38,20 @@
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.types.EnumeratedAttribute;
+import org.apache.tools.ant.types.Resource;
+import org.apache.tools.ant.types.ResourceCollection;
+import org.apache.tools.ant.types.resources.FileResource;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.Date;
+import java.util.Iterator;
 import java.util.Properties;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Set;
 import java.util.ArrayList;
+import java.util.Vector;
 import java.text.ParseException;
 
 /**
@@ -55,9 +60,9 @@
  */
 public class IndexTask extends Task {
   /**
-   *  file list
+   *  resources
    */
-  private ArrayList filesets = new ArrayList();
+  protected Vector rcs = new Vector();
 
   /**
    *  overwrite index?
@@ -173,9 +178,18 @@
    *@param  set  FileSet to be added
    */
   public void addFileset(FileSet set) {
-    filesets.add(set);
+    add(set);
   }
 
+    /**
+     * Add a collection of files to copy.
+     * @param res a resource collection to copy.
+     * @since Ant 1.7
+     */
+    public void add(ResourceCollection res) {
+        rcs.add(res);
+    }
+
   /**
    * Sets custom properties for a configurable document handler.
    */
@@ -267,18 +281,20 @@
     try {
       writer.setMergeFactor(mergeFactor);
 
-      for (int i = 0; i < filesets.size(); i++) {
-        FileSet fs = (FileSet) filesets.get(i);
-        if (fs != null) {
-          DirectoryScanner ds =
-            fs.getDirectoryScanner(getProject());
-          String[] dsfiles = ds.getIncludedFiles();
-          File baseDir = ds.getBasedir();
-
-          for (int j = 0; j < dsfiles.length; j++) {
-            File file = new File(baseDir, dsfiles[j]);
+      for (int i = 0; i < rcs.size(); i++) {
+      	ResourceCollection rc = (ResourceCollection) rcs.elementAt(i);
+        if (rc.isFilesystemOnly()) {
+          Iterator resources = rc.iterator();
+          while (resources.hasNext()) {
+            Resource r = (Resource) resources.next();
+            if (!r.isExists() || !(r instanceof FileResource)) {
+              continue;
+            }
+            
             totalFiles++;
 
+            File file = ((FileResource) r).getFile();
+            
             if (!file.exists() || !file.canRead()) {
               throw new BuildException("File \"" +
                                        file.getAbsolutePath()

Modified: lucene/java/trunk/contrib/ant/src/test/org/apache/lucene/ant/IndexTaskTest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/ant/src/test/org/apache/lucene/ant/IndexTaskTest.java?rev=786610&r1=786609&r2=786610&view=diff
==============================================================================
--- lucene/java/trunk/contrib/ant/src/test/org/apache/lucene/ant/IndexTaskTest.java (original)
+++ lucene/java/trunk/contrib/ant/src/test/org/apache/lucene/ant/IndexTaskTest.java Fri Jun
19 18:24:19 2009
@@ -59,6 +59,7 @@
 
         IndexTask task = new IndexTask();
         FileSet fs = new FileSet();
+        fs.setProject(project);
         fs.setDir(new File(docsDir));
         task.addFileset(fs);
         task.setOverwrite(true);



Mime
View raw message