lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r384336 - in /lucene/java/trunk/contrib/ant: build.xml src/java/org/apache/lucene/ant/IndexTask.java src/java/org/apache/lucene/ant/antlib.xml
Date Wed, 08 Mar 2006 21:32:06 GMT
Author: ehatcher
Date: Wed Mar  8 13:32:04 2006
New Revision: 384336

URL: http://svn.apache.org/viewcvs?rev=384336&view=rev
Log:
Modified lastmodified field to use DateTools instead of the deprecated DateField, and added
an antlib.xml file to make Ant integration easier

Added:
    lucene/java/trunk/contrib/ant/src/java/org/apache/lucene/ant/antlib.xml
Modified:
    lucene/java/trunk/contrib/ant/build.xml
    lucene/java/trunk/contrib/ant/src/java/org/apache/lucene/ant/IndexTask.java

Modified: lucene/java/trunk/contrib/ant/build.xml
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/ant/build.xml?rev=384336&r1=384335&r2=384336&view=diff
==============================================================================
--- lucene/java/trunk/contrib/ant/build.xml (original)
+++ lucene/java/trunk/contrib/ant/build.xml Wed Mar  8 13:32:04 2006
@@ -15,5 +15,11 @@
                refid="additional.dependencies"
   />
 
+  <target name="compile-core" depends="common.compile-core">
+    <copy todir="${build.dir}/classes/java">
+      <fileset dir="src/java" includes="**/*.xml"/>
+    </copy>
+  </target>
+
   <import file="../contrib-build.xml"/>
 </project>

Modified: lucene/java/trunk/contrib/ant/src/java/org/apache/lucene/ant/IndexTask.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/ant/src/java/org/apache/lucene/ant/IndexTask.java?rev=384336&r1=384335&r2=384336&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 Wed Mar  8
13:32:04 2006
@@ -21,9 +21,9 @@
 import org.apache.lucene.analysis.SimpleAnalyzer;
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.document.DateField;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.DateTools;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.Hits;
@@ -46,6 +46,7 @@
 import java.util.HashMap;
 import java.util.Set;
 import java.util.ArrayList;
+import java.text.ParseException;
 
 /**
  *  Ant task to index files with Lucene
@@ -139,7 +140,7 @@
   /**
    * If creating a new index and this is set to true, the
    * index will be created in compound format.
-   */ 
+   */
   public void setUseCompoundIndex(boolean useCompoundIndex) {
     this.useCompoundIndex = useCompoundIndex;
   }
@@ -302,8 +303,13 @@
                 String indexModified =
                   doc.get("modified").trim();
                 if (indexModified != null) {
-                  if (DateField.stringToTime(indexModified)
-                    == file.lastModified()) {
+                  long lastModified = 0;
+                  try {
+                    lastModified = DateTools.stringToTime(indexModified);
+                  } catch (ParseException e) {
+                    // if modified time is not parsable, skip
+                  }
+                  if (lastModified == file.lastModified()) {
                     // TODO: remove existing document
                     indexIt = false;
                   }
@@ -328,7 +334,7 @@
                   // Add the last modified date of the file a field named "modified".  Use
a
                   // Keyword field, so that it's searchable, but so that no attempt is made
                   // to tokenize the field into words.
-                  doc.add(new Field("modified", DateField.timeToString(file.lastModified()),
Field.Store.YES, Field.Index.UN_TOKENIZED));
+                  doc.add(new Field("modified", DateTools.timeToString(file.lastModified(),
DateTools.Resolution.MILLISECOND), Field.Store.YES, Field.Index.UN_TOKENIZED));
 
                   writer.addDocument(doc);
                   totalIndexed++;

Added: lucene/java/trunk/contrib/ant/src/java/org/apache/lucene/ant/antlib.xml
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/ant/src/java/org/apache/lucene/ant/antlib.xml?rev=384336&view=auto
==============================================================================
--- lucene/java/trunk/contrib/ant/src/java/org/apache/lucene/ant/antlib.xml (added)
+++ lucene/java/trunk/contrib/ant/src/java/org/apache/lucene/ant/antlib.xml Wed Mar  8 13:32:04
2006
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<antlib>
+  <taskdef name="index" classname="org.apache.lucene.ant.IndexTask"/>
+</antlib>



Mime
View raw message