umagesh 2002/05/31 15:31:31
Modified: . Tag: ANT_15_BRANCH build.xml
docs/manual/CoreTypes Tag: ANT_15_BRANCH selectors.html
src/main/org/apache/tools/ant/types/selectors Tag:
ANT_15_BRANCH DateSelector.java DependSelector.java
DepthSelector.java FilenameSelector.java
PresentSelector.java
Added: src/etc/testcases/types Tag: ANT_15_BRANCH selectors.xml
src/testcases/org/apache/tools/ant/types/selectors Tag:
ANT_15_BRANCH BaseSelectorTest.java
ContainsSelectorTest.java DateSelectorTest.java
DependSelectorTest.java DepthSelectorTest.java
FilenameSelectorTest.java PresentSelectorTest.java
SizeSelectorTest.java
Log:
Test cases to selectors and a few minor bug fixes.
DaleSelectorTest's "equals" tests failed for me and hence I am commenting it
out for now.
Submitted by: Bruce Atherton <[EMAIL PROTECTED]>
Revision Changes Path
No revision
No revision
1.304.2.13 +1 -0 jakarta-ant/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/build.xml,v
retrieving revision 1.304.2.12
retrieving revision 1.304.2.13
diff -u -r1.304.2.12 -r1.304.2.13
--- build.xml 28 May 2002 11:50:38 -0000 1.304.2.12
+++ build.xml 31 May 2002 22:31:30 -0000 1.304.2.13
@@ -1235,6 +1235,7 @@
<exclude name="${regexp.package}/RegexpTest.java" />
<exclude name="${optional.package}/AbstractXSLTLiaisonTest.java" />
<exclude name="${ant.package}/types/AbstractFileSetTest.java" />
+ <exclude
name="${ant.package}/types/selectors/BaseSelectorTest.java" />
<!-- helper classes, not testcases -->
<exclude name="org/example/**" />
No revision
No revision
1.1.2.4 +15 -2 jakarta-ant/docs/manual/CoreTypes/Attic/selectors.html
Index: selectors.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTypes/Attic/selectors.html,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- selectors.html 27 May 2002 07:11:04 -0000 1.1.2.3
+++ selectors.html 31 May 2002 22:31:30 -0000 1.1.2.4
@@ -130,6 +130,18 @@
</td>
</tr>
<tr>
+ <td valign="top">granularity</td>
+ <td valign="top">The number of milliseconds leeway to give before
+ deciding whether a files modification time matches a date. This is
+ needed because not every file system supports tracking the last
+ modified time to the millisecond level. The file will be selected
+ provided the condition could be true were the granularity added or
+ subtracted from the actual time. Default is 0 milliseconds except
+ on Windows systems, where it is 2000 milliseconds (2 seconds).
+ </td>
+ <td valign="top" align="center">No</td>
+ </tr>
+ <tr>
<td valign="top">when</td>
<td valign="top">Indicates how to interpret the date, whether
the files to be selected are those whose last modified times should
@@ -189,7 +201,8 @@
<td valign="top">The number of milliseconds leeway to give before
deciding a file is out of date. This is needed because not every
file system supports tracking the last modified time to the
- millisecond level. Default is 0 milliseconds.
+ millisecond level. Default is 0 milliseconds except on Windows
+ systems, where it is 2000 milliseconds (2 seconds).
</td>
<td valign="top" align="center">No</td>
</tr>
@@ -203,7 +216,7 @@
</fileset>
</pre></blockquote>
- <p>Selects all the Java source files which were modified in the
+ <p>Selects all the Java source files which were modified in the
1.5 release.
</p>
No revision
No revision
1.1.2.1 +60 -0 jakarta-ant/src/etc/testcases/types/Attic/selectors.xml
No revision
No revision
1.1.2.2 +36 -4
jakarta-ant/src/main/org/apache/tools/ant/types/selectors/DateSelector.java
Index: DateSelector.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/selectors/DateSelector.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- DateSelector.java 24 May 2002 23:56:26 -0000 1.1.2.1
+++ DateSelector.java 31 May 2002 22:31:31 -0000 1.1.2.2
@@ -62,6 +62,7 @@
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.Parameter;
+import org.apache.tools.ant.taskdefs.condition.Os;
/**
* Selector that chooses files based on their last modified date.
@@ -74,19 +75,24 @@
private long millis = -1;
private String dateTime = null;
private boolean includeDirs = false;
+ private int granularity = 0;
private int cmp = 2;
public final static String MILLIS_KEY = "millis";
public final static String DATETIME_KEY = "datetime";
public final static String CHECKDIRS_KEY = "checkdirs";
+ public final static String GRANULARITY_KEY = "granularity";
public final static String WHEN_KEY = "when";
public DateSelector() {
+ if (Os.isFamily("dos")) {
+ granularity = 2000;
+ }
}
public String toString() {
StringBuffer buf = new StringBuffer("{dateselector date: ");
buf.append(dateTime);
- buf.append("compare: ");
+ buf.append(" compare: ");
if (cmp == 0) {
buf.append("before");
}
@@ -95,6 +101,8 @@
} else {
buf.append("equal");
}
+ buf.append(" granularity: ");
+ buf.append(granularity);
buf.append("}");
return buf.toString();
}
@@ -110,6 +118,13 @@
}
/**
+ * Returns the millisecond value the selector is set for.
+ */
+ public long getMillis() {
+ return millis;
+ }
+
+ /**
* Sets the date. The user must supply it in MM/DD/YYYY HH:MM AM_PM
* format
*
@@ -147,6 +162,14 @@
}
/**
+ * Sets the number of milliseconds leeway we will give before we consider
+ * a file not to have matched a date.
+ */
+ public void setGranularity(int granularity) {
+ this.granularity = granularity;
+ }
+
+ /**
* Sets the type of comparison to be done on the file's last modified
* date.
*
@@ -182,6 +205,15 @@
else if (CHECKDIRS_KEY.equalsIgnoreCase(paramname)) {
setCheckdirs(Project.toBoolean(parameters[i].getValue()));
}
+ else if (GRANULARITY_KEY.equalsIgnoreCase(paramname)) {
+ try {
+ setGranularity(new Integer(parameters[i].getValue()
+ ).intValue());
+ } catch (NumberFormatException nfe) {
+ setError("Invalid granularity setting " +
+ parameters[i].getValue());
+ }
+ }
else if (WHEN_KEY.equalsIgnoreCase(paramname)) {
TimeComparisons cmp = new TimeComparisons();
cmp.setValue(parameters[i].getValue());
@@ -225,13 +257,13 @@
return true;
}
if (cmp == 0) {
- return (file.lastModified() < millis);
+ return ((file.lastModified() - granularity) < millis);
}
else if (cmp == 1) {
- return (file.lastModified() > millis);
+ return ((file.lastModified() + granularity) > millis);
}
else {
- return (file.lastModified() == millis);
+ return (Math.abs(file.lastModified() - millis) <= granularity);
}
}
1.1.2.1 +9 -0
jakarta-ant/src/main/org/apache/tools/ant/types/selectors/DependSelector.java
Index: DependSelector.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/selectors/DependSelector.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- DependSelector.java 30 Apr 2002 22:38:35 -0000 1.1
+++ DependSelector.java 31 May 2002 22:31:31 -0000 1.1.2.1
@@ -61,6 +61,7 @@
import org.apache.tools.ant.util.IdentityMapper;
import org.apache.tools.ant.util.FileNameMapper;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.condition.Os;
/**
* Selector that filters files based on whether they are newer than
@@ -80,6 +81,9 @@
private int granularity = 0;
public DependSelector() {
+ if (Os.isFamily("dos")) {
+ granularity = 2000;
+ }
}
public String toString() {
@@ -171,6 +175,11 @@
// Determine file whose out-of-dateness is to be checked
String[] destfiles = map.mapFileName(filename);
+ // If filename does not match the To attribute of the mapper
+ // then filter it out of the files we are considering
+ if (destfiles == null) {
+ return false;
+ }
// Sanity check
if (destfiles.length != 1 || destfiles[0] == null) {
throw new BuildException("Invalid destination file results for "
1.1.2.2 +1 -1
jakarta-ant/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java
Index: DepthSelector.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/selectors/DepthSelector.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- DepthSelector.java 24 May 2002 23:56:26 -0000 1.1.2.1
+++ DepthSelector.java 31 May 2002 22:31:31 -0000 1.1.2.2
@@ -150,7 +150,7 @@
setError("You must set at least one of the min or the " +
"max levels.");
}
- if (max < min) {
+ if (max < min && max > -1) {
setError("The maximum depth is lower than the minimum.");
}
}
1.1.2.3 +2 -2
jakarta-ant/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java
Index: FilenameSelector.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/selectors/FilenameSelector.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- FilenameSelector.java 24 May 2002 23:56:26 -0000 1.1.2.2
+++ FilenameSelector.java 31 May 2002 22:31:31 -0000 1.1.2.3
@@ -187,8 +187,8 @@
public boolean isSelected(File basedir, String filename, File file) {
validate();
- return SelectorUtils.matchPath(pattern,filename,
- casesensitive);
+ return (SelectorUtils.matchPath(pattern,filename,
+ casesensitive) == !(negated));
}
}
1.1.2.1 +5 -0
jakarta-ant/src/main/org/apache/tools/ant/types/selectors/PresentSelector.java
Index: PresentSelector.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/selectors/PresentSelector.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- PresentSelector.java 30 Apr 2002 22:38:36 -0000 1.1
+++ PresentSelector.java 31 May 2002 22:31:31 -0000 1.1.2.1
@@ -184,6 +184,11 @@
// Determine file whose existence is to be checked
String[] destfiles = map.mapFileName(filename);
+ // If filename does not match the To attribute of the mapper
+ // then filter it out of the files we are considering
+ if (destfiles == null) {
+ return false;
+ }
// Sanity check
if (destfiles.length != 1 || destfiles[0] == null) {
throw new BuildException("Invalid destination file results for "
No revision
No revision
1.1.2.1 +192 -0
jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/Attic/BaseSelectorTest.java
1.1.2.1 +153 -0
jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/Attic/ContainsSelectorTest.java
1.1.2.1 +265 -0
jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/Attic/DateSelectorTest.java
1.1.2.1 +176 -0
jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/Attic/DependSelectorTest.java
1.1.2.1 +200 -0
jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/Attic/DepthSelectorTest.java
1.1.2.1 +167 -0
jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/Attic/FilenameSelectorTest.java
1.1.2.1 +177 -0
jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/Attic/PresentSelectorTest.java
1.1.2.1 +243 -0
jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/Attic/SizeSelectorTest.java
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>