umagesh 01/12/30 11:39:23
Modified: src/main/org/apache/tools/ant/taskdefs Checksum.java
Expand.java LoadFile.java Mkdir.java Property.java
Unpack.java
src/testcases/org/apache/tools/ant/taskdefs
LoadFileTest.java
Log:
Usage of SrcFile,SrcDir,DestFile,DestDir abandoned. Rolling back to
previous state.
Revision Changes Path
1.7 +7 -3
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Checksum.java
Index: Checksum.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Checksum.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Checksum.java 25 Dec 2001 20:07:14 -0000 1.6
+++ Checksum.java 30 Dec 2001 19:39:23 -0000 1.7
@@ -72,7 +72,6 @@
import org.apache.tools.ant.taskdefs.condition.Condition;
import org.apache.tools.ant.taskdefs.MatchingTask;
import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.types.SrcFile;
/**
* This task can be used to create checksums for files.
@@ -130,8 +129,8 @@
/**
* Sets the file for which the checksum is to be calculated.
*/
- public void setFile(SrcFile file) {
- this.file = file.getFile();
+ public void setFile(File file) {
+ this.file = file;
}
/**
@@ -218,6 +217,11 @@
if (file == null && filesets.size() == 0) {
throw new BuildException(
"Specify at least one source - a file or a fileset.");
+ }
+
+ if (file != null && file.exists() && file.isDirectory()) {
+ throw new BuildException(
+ "Checksum cannot be generated for directories");
}
if (property != null && fileext != null) {
1.22 +12 -36
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Expand.java
Index: Expand.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Expand.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Expand.java 28 Dec 2001 20:27:43 -0000 1.21
+++ Expand.java 30 Dec 2001 19:39:23 -0000 1.22
@@ -57,10 +57,8 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.DestDir;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet;
-import org.apache.tools.ant.types.SrcFile;
import org.apache.tools.ant.util.FileUtils;
import java.io.File;
import java.io.FileInputStream;
@@ -106,10 +104,19 @@
"Dest attribute must be specified");
}
+ if (dest.exists() && !dest.isDirectory()) {
+ throw new BuildException("Dest must be a directory.", location);
+ }
+
FileUtils fileUtils = FileUtils.newFileUtils();
if (source != null) {
- expandFile(fileUtils, source, dest);
+ if (source.isDirectory()) {
+ throw new BuildException("Src must not be a directory." +
+ " Use nested filesets instead.", location);
+ } else {
+ expandFile(fileUtils, source, dest);
+ }
}
if (filesets.size() > 0) {
for (int j=0; j < filesets.size(); j++) {
@@ -246,49 +253,18 @@
* destination directory.
*
* @param d Path to the directory.
- * @deprecated setDest(File) is deprecated and is replaced with
- * setDest(DestDir) to let Ant's core perform validation
*/
public void setDest(File d) {
- log("DEPRECATED - The setDest(File) method has been deprecated."
- + " Use setDest(DestDir) instead.");
- DestDir dd = new DestDir();
- dd.setFile(d);
- setDest(dd);
- }
-
- /**
- * Set the destination directory. File will be unzipped into the
- * destination directory.
- *
- * @param d Path to the directory.
- */
- public void setDest(DestDir d) {
- this.dest=d.getFile();
+ this.dest=d;
}
/**
* Set the path to zip-file.
*
* @param s Path to zip-file.
- * @deprecated setSrc(File) is deprecated and is replaced with
- * setSrc(SrcFile) to let Ant's core perform validation
*/
public void setSrc(File s) {
- log("DEPRECATED - The setSrc(File) method has been deprecated."
- + " Use setSrc(SrcFile) instead.");
- SrcFile sf = new SrcFile();
- sf.setFile(s);
- setSrc(sf);
- }
-
- /**
- * Set the path to zip-file.
- *
- * @param s Path to zip-file.
- */
- public void setSrc(SrcFile s) {
- this.source = s.getFile();
+ this.source = s;
}
/**
1.3 +5 -6
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/LoadFile.java
Index: LoadFile.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/LoadFile.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LoadFile.java 27 Dec 2001 05:18:00 -0000 1.2
+++ LoadFile.java 30 Dec 2001 19:39:23 -0000 1.3
@@ -58,7 +58,7 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.types.EnumeratedAttribute;
-import org.apache.tools.ant.types.SrcFile;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
@@ -67,7 +67,7 @@
/**
* Load a file into a property
- * @since 1.5
+ *
* @author Steve Loughran
* @created 10 December 2001
*/
@@ -126,8 +126,8 @@
*
* @param srcFile The new SrcFile value
*/
- public void setSrcFile(SrcFile srcFile) {
- this.srcFile = srcFile.getFile();
+ public void setSrcFile(File srcFile) {
+ this.srcFile = srcFile;
}
@@ -182,7 +182,7 @@
project.setNewProperty(property, text);
log("loaded "+buffer.length+" characters",Project.MSG_VERBOSE);
log(property+" := "+text,Project.MSG_DEBUG);
-
+
} catch (IOException ioe) {
String message = "Unable to load file: " + ioe.toString();
if (failOnError) {
@@ -203,4 +203,3 @@
//end class
}
-
1.12 +8 -17
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Mkdir.java
Index: Mkdir.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Mkdir.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Mkdir.java 27 Dec 2001 21:47:17 -0000 1.11
+++ Mkdir.java 30 Dec 2001 19:39:23 -0000 1.12
@@ -54,11 +54,9 @@
package org.apache.tools.ant.taskdefs;
-import java.io.File;
-import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.DestDir;
-
+import org.apache.tools.ant.BuildException;
+import java.io.File;
/**
* Creates a given directory.
@@ -75,6 +73,10 @@
throw new BuildException("dir attribute is required", location);
}
+ if (dir.isFile()) {
+ throw new BuildException("Unable to create directory as a file
already exists with that name: " + dir.getAbsolutePath());
+ }
+
if (!dir.exists()) {
boolean result = dir.mkdirs();
if (result == false) {
@@ -86,19 +88,8 @@
}
}
- /**
- * @deprecated setDir(File) is deprecated and is replaced with
- * setDir(DestDir) to let Ant's core perform validation
- */
public void setDir(File dir) {
- log("DEPRECATED - The setDir(File) method has been deprecated."
- + " Use setDir(DestDir) instead.");
- DestDir destDir = new DestDir();
- destDir.setFile(dir);
- setDir(destDir);
- }
-
- public void setDir(DestDir destDir) {
- this.dir = destDir.getFile();
+ this.dir = dir;
}
}
+
1.40 +1 -14
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java
Index: Property.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Property.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- Property.java 28 Dec 2001 21:45:29 -0000 1.39
+++ Property.java 30 Dec 2001 19:39:23 -0000 1.40
@@ -59,7 +59,6 @@
import org.apache.tools.ant.Project;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.ProjectHelper;
-import org.apache.tools.ant.types.DestFile;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
import java.io.File;
@@ -118,20 +117,8 @@
return value;
}
- /**
- * @deprecated setFile(File) is deprecated and is replaced with
- * setFile(DestFile) to let Ant's core perform validation
- */
public void setFile(File file) {
- log("DEPRECATED - The setFile(File) method has been deprecated."
- + " Use setFile(DestFile) instead.");
- DestFile destFile = new DestFile();
- destFile.setFile(file);
- setFile(destFile);
- }
-
- public void setFile(DestFile file) {
- this.file = file.getFile();
+ this.file = file;
}
public File getFile() {
1.4 +13 -8
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Unpack.java
Index: Unpack.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Unpack.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Unpack.java 25 Dec 2001 19:54:44 -0000 1.3
+++ Unpack.java 30 Dec 2001 19:39:23 -0000 1.4
@@ -58,7 +58,6 @@
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.SrcFile;
/**
* Abstract Base class for unpack tasks.
@@ -73,16 +72,14 @@
/**
* @deprecated setSrc(String) is deprecated and is replaced with
- * setSrc(SrcFile) to make Ant's Introspection
+ * setSrc(File) to make Ant's Introspection
* mechanism do the work and also to encapsulate operations
on
* the type in its own class.
*/
public void setSrc(String src) {
log("DEPRECATED - The setSrc(String) method has been deprecated."
- + " Use setSrc(SrcFile) instead.");
- SrcFile sf = new SrcFile();
- sf.setFile(project.resolveFile(src));
- setSrc(sf);
+ + " Use setSrc(File) instead.");
+ setSrc(project.resolveFile(src));
}
/**
@@ -97,8 +94,8 @@
setDest(project.resolveFile(dest));
}
- public void setSrc(SrcFile srcFile) {
- source = srcFile.getFile();
+ public void setSrc(File src) {
+ source = src;
}
public void setDest(File dest) {
@@ -108,6 +105,14 @@
private void validate() throws BuildException {
if (source == null) {
throw new BuildException("No Src specified", location);
+ }
+
+ if (!source.exists()) {
+ throw new BuildException("Src doesn't exist", location);
+ }
+
+ if (source.isDirectory()) {
+ throw new BuildException("Cannot expand a directory", location);
}
if (dest == null) {
1.4 +7 -13
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/LoadFileTest.java
Index: LoadFileTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/LoadFileTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LoadFileTest.java 27 Dec 2001 05:18:14 -0000 1.3
+++ LoadFileTest.java 30 Dec 2001 19:39:23 -0000 1.4
@@ -116,32 +116,25 @@
public void testNoSourcefilefound() {
expectBuildExceptionContaining("testNoSourcefilefound",
"File not found",
- "does not exist");
+ "Unable to load file");
}
/**
* A unit test for JUnit
*/
- /* turned off as the move to SrcFile changed where the check
- * for existence went.
- * we need to think of an alternate way to generate a file which
- * cant be opened for reading
- */
- /*
- public void testFailOnError()
+ public void testFailOnError()
throws BuildException {
executeTarget("testFailOnError");
if(project.getProperty("testFailOnError")!=null) {
- fail("property should not have been defined");
+ fail("property should not have been defined");
}
}
- */
-
+
/**
* A unit test for JUnit
*/
- public void testLoadAFile()
+ public void testLoadAFile()
throws BuildException {
executeTarget("testLoadAFile");
if(project.getProperty("testLoadAFile").indexOf("eh?")<0) {
@@ -153,7 +146,7 @@
/**
* A unit test for JUnit
*/
- public void testLoadAFileEnc()
+ public void testLoadAFileEnc()
throws BuildException {
executeTarget("testLoadAFileEnc");
if(project.getProperty("testLoadAFileEnc")==null) {
@@ -163,4 +156,5 @@
}
}
+
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>