diff --git a/src/main/org/apache/tools/ant/taskdefs/Exit.java b/src/main/org/apache/tools/ant/taskdefs/Exit.java
index 37e9d0c49..53e2ef84b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Exit.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Exit.java
@@ -64,6 +64,8 @@ import org.apache.tools.ant.BuildException;
*
* @author Nico Seessle
*
+ * @since Ant 1.2
+ *
* @ant.task name="fail" category="control"
*/
public class Exit extends Task {
diff --git a/src/main/org/apache/tools/ant/taskdefs/Filter.java b/src/main/org/apache/tools/ant/taskdefs/Filter.java
index 43a29ddbf..e413f8d58 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Filter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Filter.java
@@ -54,11 +54,8 @@
package org.apache.tools.ant.taskdefs;
-
-
import java.io.File;
-
import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -72,6 +69,8 @@ import org.apache.tools.ant.Project;
* @author Gero Vermaas gero@xs4all.nl
* @author Michael McCallum
*
+ * @since Ant 1.1
+ *
* @ant.task category="filesystem"
*/
public class Filter extends Task {
@@ -93,11 +92,15 @@ public class Filter extends Task {
}
public void execute() throws BuildException {
- boolean isFiltersFromFile = filtersFile != null && token == null && value == null;
- boolean isSingleFilter = filtersFile == null && token != null && value != null;
+ boolean isFiltersFromFile =
+ filtersFile != null && token == null && value == null;
+ boolean isSingleFilter =
+ filtersFile == null && token != null && value != null;
if (!isFiltersFromFile && !isSingleFilter) {
- throw new BuildException("both token and value parameters, or only a filtersFile parameter is required", location);
+ throw new BuildException("both token and value parameters, or "
+ + "only a filtersFile parameter is "
+ + "required", location);
}
if (isSingleFilter) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
index da69ddd54..8ad68e7a7 100644
--- a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
+++ b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
@@ -117,6 +117,7 @@ import java.util.NoSuchElementException;
* @author Sam Ruby rubys@us.ibm.com
* @author Peter B. West
* @version $Revision$ $Name$
+ * @since Ant 1.1
*
* @ant.task category="filesystem"
*/
@@ -309,7 +310,7 @@ public class FixCRLF extends MatchingTask {
}
/**
- * Specify how DOS EOF (control-z) charaters are to be handled
+ * Specify how DOS EOF (control-z) characters are to be handled
*
* @param option valid values:
*
@@ -405,7 +406,8 @@ public class FixCRLF extends MatchingTask {
try {
tmpFile = fileUtils.createTempFile("fixcrlf", "", destD);
Writer writer = (encoding == null) ? new FileWriter(tmpFile)
- : new OutputStreamWriter(new FileOutputStream(tmpFile), encoding);
+ : new OutputStreamWriter(new FileOutputStream(tmpFile),
+ encoding);
outWriter = new BufferedWriter(writer);
} catch (IOException e) {
throw new BuildException(e);
@@ -469,11 +471,13 @@ public class FixCRLF extends MatchingTask {
case IN_CHAR_CONST:
case IN_STR_CONST:
- // Got here from LOOKING by finding an opening "\'"
- // next points to that quote character.
- // Find the end of the constant. Watch out for
- // backslashes. Literal tabs are left unchanged, and
- // the column is adjusted accordingly.
+ // Got here from LOOKING by finding an
+ // opening "\'" next points to that quote
+ // character.
+ // Find the end of the constant. Watch
+ // out for backslashes. Literal tabs are
+ // left unchanged, and the column is
+ // adjusted accordingly.
int begin = line.getNext();
char terminator = (lines.getState() == IN_STR_CONST
@@ -482,10 +486,10 @@ public class FixCRLF extends MatchingTask {
endOfCharConst(line, terminator);
while (line.getNext() < line.getLookahead()) {
if (line.getNextCharInc() == '\t') {
- line.setColumn(
- line.getColumn() +
+ line.setColumn(line.getColumn() +
tablength -
- line.getColumn() % tablength);
+ (line.getColumn()
+ % tablength));
}
else {
line.incColumn();
@@ -494,7 +498,8 @@ public class FixCRLF extends MatchingTask {
// Now output the substring
try {
- outWriter.write(line.substring(begin, line.getNext()));
+ outWriter.write(line.substring(begin,
+ line.getNext()));
} catch (IOException e) {
throw new BuildException(e);
}
@@ -541,16 +546,17 @@ public class FixCRLF extends MatchingTask {
}
- File destFile = new File(destD, file);
-
try {
lines.close();
lines = null;
}
catch (IOException e) {
- throw new BuildException("Unable to close source file " + srcFile);
+ throw new BuildException("Unable to close source file "
+ + srcFile);
}
+ File destFile = new File(destD, file);
+
if (destFile.exists()) {
// Compare the destination with the temp file
log("destFile exists", Project.MSG_DEBUG);
diff --git a/src/main/org/apache/tools/ant/taskdefs/GenerateKey.java b/src/main/org/apache/tools/ant/taskdefs/GenerateKey.java
index 38bbb1f98..4ac6bdcbf 100644
--- a/src/main/org/apache/tools/ant/taskdefs/GenerateKey.java
+++ b/src/main/org/apache/tools/ant/taskdefs/GenerateKey.java
@@ -65,6 +65,8 @@ import org.apache.tools.ant.types.Commandline;
*
* @author Peter Donald
*
+ * @since Ant 1.2
+ *
* @ant.task name="genkey" category="java"
*/
public class GenerateKey extends Task {
@@ -172,10 +174,12 @@ public class GenerateKey extends Task {
public DistinguishedName createDname() throws BuildException {
if( null != expandedDname ) {
- throw new BuildException( "DName sub-element can only be specified once." );
+ throw new BuildException( "DName sub-element can only be "
+ + "specified once." );
}
if( null != dname ) {
- throw new BuildException( "It is not possible to specify dname both " +
+ throw new BuildException( "It is not possible to specify dname " +
+ " both " +
"as attribute and element." );
}
expandedDname = new DistinguishedName();
@@ -184,11 +188,12 @@ public class GenerateKey extends Task {
public void setDname(final String dname) {
if( null != expandedDname ) {
- throw new BuildException( "It is not possible to specify dname both " +
+ throw new BuildException( "It is not possible to specify dname " +
+ " both " +
"as attribute and element." );
}
this.dname = dname;
- }
+ }
public void setAlias(final String alias) {
this.alias = alias;
@@ -240,9 +245,9 @@ public class GenerateKey extends Task {
public void execute() throws BuildException {
if (Project.getJavaVersion().equals(Project.JAVA_1_1)) {
- throw new BuildException( "The genkey task is only available on JDK" +
- " versions 1.2 or greater" );
- }
+ throw new BuildException( "The genkey task is only available on JDK"
+ + " versions 1.2 or greater" );
+ }
if (null == alias) {
throw new BuildException( "alias attribute must be set" );
diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java
index b36f1a3d6..5ebc560b0 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Get.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Get.java
@@ -62,9 +62,10 @@ import java.net.URL;
import java.net.URLConnection;
import java.net.HttpURLConnection;
import java.util.Date;
-import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.util.FileUtils;
/**
* Get a particular file from a URL source.
@@ -75,6 +76,8 @@ import org.apache.tools.ant.Project;
* @author costin@dnt.ro
* @author gg@grtmail.com (Added Java 1.1 style HTTP basic auth)
*
+ * @since Ant 1.1
+ *
* @ant.task category="network"
*/
public class Get extends Task {
@@ -143,7 +146,8 @@ public class Get extends Task {
// check to see if sun's Base64 encoder is available.
try {
sun.misc.BASE64Encoder encoder =
- (sun.misc.BASE64Encoder) Class.forName("sun.misc.BASE64Encoder").newInstance();
+ (sun.misc.BASE64Encoder)
+ Class.forName("sun.misc.BASE64Encoder").newInstance();
encoding = encoder.encode (up.getBytes());
}
@@ -151,7 +155,8 @@ public class Get extends Task {
Base64Converter encoder = new Base64Converter();
encoding = encoder.encode(up.getBytes());
}
- connection.setRequestProperty ("Authorization", "Basic " + encoding);
+ connection.setRequestProperty ("Authorization",
+ "Basic " + encoding);
}
//connect to the remote site (may take some time)
@@ -159,24 +164,29 @@ public class Get extends Task {
//next test for a 304 result (HTTP only)
if(connection instanceof HttpURLConnection) {
HttpURLConnection httpConnection=(HttpURLConnection)connection;
- if(httpConnection.getResponseCode()==HttpURLConnection.HTTP_NOT_MODIFIED) {
- //not modified so no file download. just return instead
- //and trace out something so the user doesn't think that the
- //download happened when it didnt
+ if(httpConnection.getResponseCode()
+ == HttpURLConnection.HTTP_NOT_MODIFIED) {
+ //not modified so no file download. just return
+ //instead and trace out something so the user
+ //doesn't think that the download happened when it
+ //didnt
log("Not modified - so not downloaded");
return;
}
// test for 401 result (HTTP only)
- if(httpConnection.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED) {
+ if(httpConnection.getResponseCode()
+ == HttpURLConnection.HTTP_UNAUTHORIZED) {
log("Not authorized - check " + dest + " for details");
return;
}
}
- //REVISIT: at this point even non HTTP connections may support the if-modified-since
- //behaviour -we just check the date of the content and skip the write if it is not
- //newer. Some protocols (FTP) dont include dates, of course.
+ //REVISIT: at this point even non HTTP connections may
+ //support the if-modified-since behaviour -we just check
+ //the date of the content and skip the write if it is not
+ //newer. Some protocols (FTP) dont include dates, of
+ //course.
FileOutputStream fos = new FileOutputStream(dest);
@@ -204,26 +214,30 @@ public class Get extends Task {
while ((length = is.read(buffer)) >= 0) {
fos.write(buffer, 0, length);
if (verbose) {
- System.out.print(".");
+ System.out.print(".");
}
}
if(verbose) {
- System.out.println();
+ System.out.println();
}
fos.close();
is.close();
- //if (and only if) the use file time option is set, then the
- //saved file now has its timestamp set to that of the downloaded file
+ //if (and only if) the use file time option is set, then
+ //the saved file now has its timestamp set to that of the
+ //downloaded file
if(useTimestamp) {
long remoteTimestamp=connection.getLastModified();
if (verbose) {
Date t=new Date(remoteTimestamp);
log("last modified = "+t.toString()
- +((remoteTimestamp==0)?" - using current time instead":""));
+ +((remoteTimestamp==0)
+ ? " - using current time instead"
+ : ""));
}
if(remoteTimestamp!=0) {
- touchFile(dest,remoteTimestamp);
+ FileUtils.newFileUtils()
+ .setFileLastModified(dest, remoteTimestamp);
}
}
} catch (IOException ioe) {
@@ -235,34 +249,6 @@ public class Get extends Task {
}
}
- /**
- * set the timestamp of a named file to a specified time.
- *
- * @param filename
- * @param time in milliseconds since the start of the era
- * @return true if it succeeded. False means that this is a
- * java1.1 system and that file times can not be set
- *@exception BuildException Thrown in unrecoverable error. Likely
- *this comes from file access failures.
- */
- protected boolean touchFile(File file, long timemillis)
- throws BuildException {
-
- if (Project.getJavaVersion() != Project.JAVA_1_1) {
- Touch touch = (Touch) project.createTask("touch");
- touch.setOwningTarget(target);
- touch.setTaskName(getTaskName());
- touch.setLocation(getLocation());
- touch.setFile(file);
- touch.setMillis(timemillis);
- touch.touch();
- return true;
-
- } else {
- return false;
- }
- }
-
/**
* Set the URL.
*
@@ -302,16 +288,18 @@ public class Get extends Task {
/**
* Use timestamps, if set to "true
".
*
- * In this situation, the if-modified-since header is set so that the file is
- * only fetched if it is newer than the local file (or there is no local file)
- * This flag is only valid on HTTP connections, it is ignored in other cases.
- * When the flag is set, the local copy of the downloaded file will also
- * have its timestamp set to the remote file time.
- *
- * Note that remote files of date 1/1/1970 (GMT) are treated as 'no timestamp', and
- * web servers often serve files with a timestamp in the future by replacing their timestamp
- * with that of the current time. Also, inter-computer clock differences can cause no end of
- * grief.
+ *
In this situation, the if-modified-since header is set so
+ * that the file is only fetched if it is newer than the local
+ * file (or there is no local file) This flag is only valid on
+ * HTTP connections, it is ignored in other cases. When the flag
+ * is set, the local copy of the downloaded file will also have
+ * its timestamp set to the remote file time.
+ *
+ * Note that remote files of date 1/1/1970 (GMT) are treated as
+ * 'no timestamp', and web servers often serve files with a
+ * timestamp in the future by replacing their timestamp with that
+ * of the current time. Also, inter-computer clock differences can
+ * cause no end of grief.
* @param v "true" to enable file time fetching
*/
public void setUseTimestamp(boolean v) {
@@ -327,7 +315,7 @@ public class Get extends Task {
* @param u username for authentication
*/
public void setUsername(String u) {
- this.uname = u;
+ this.uname = u;
}
/**
@@ -336,7 +324,7 @@ public class Get extends Task {
* @param p password for authentication
*/
public void setPassword(String p) {
- this.pword = p;
+ this.pword = p;
}
/*********************************************************************
@@ -346,7 +334,7 @@ public class Get extends Task {
*
* @author
* Unknown
- * @author
+ * @author
* Gautam Guliani
*********************************************************************/
diff --git a/src/main/org/apache/tools/ant/taskdefs/Jar.java b/src/main/org/apache/tools/ant/taskdefs/Jar.java
index 946d920fc..9f8ee00ff 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Jar.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Jar.java
@@ -59,7 +59,6 @@ import org.apache.tools.ant.FileScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.ZipFileSet;
import org.apache.tools.ant.types.EnumeratedAttribute;
-import org.apache.tools.ant.util.StringUtils;
import org.apache.tools.zip.ZipOutputStream;
import java.io.IOException;