git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@470130 13f79535-47bb-0310-9956-ffa450edef68master
@@ -267,7 +267,7 @@ public class ProjectHelper { | |||
* JDK1.1 compatible access to the context class loader. | |||
* Cut&paste from JAXP. | |||
* | |||
* @deprecated since 1.6.x. | |||
* @deprecated since 1.6.x. | |||
* Use LoaderUtils.getContextClassLoader() | |||
* | |||
* @return the current context class loader, or <code>null</code> | |||
@@ -293,7 +293,7 @@ public class ProjectHelper { | |||
* @param project The project containing the target. | |||
* Must not be <code>null</code>. | |||
* | |||
* @deprecated since 1.6.x. | |||
* @deprecated since 1.6.x. | |||
* Use IntrospectionHelper for each property. | |||
* | |||
* @exception BuildException if any of the attributes can't be handled by | |||
@@ -435,7 +435,7 @@ public class ProjectHelper { | |||
* <code>}</code> | |||
* @return the original string with the properties replaced, or | |||
* <code>null</code> if the original string is <code>null</code>. | |||
* @deprecated since 1.6.x. | |||
* @deprecated since 1.6.x. | |||
* Use PropertyHelper. | |||
*/ | |||
public static String replaceProperties(Project project, String value, | |||
@@ -72,7 +72,7 @@ public abstract class Task extends ProjectComponent { | |||
/** | |||
* Wrapper for this object, used to configure it at runtime. | |||
* | |||
* @deprecated since 1.6.x. | |||
* @deprecated since 1.6.x. | |||
* You should not be accessing this variable directly. | |||
* Please use the {@link #getWrapper()} method. | |||
*/ | |||
@@ -42,11 +42,11 @@ public final class Locator { | |||
// stolen from org.apache.xerces.impl.XMLEntityManager#getUserDir() | |||
// of the Xerces-J team | |||
// which ASCII characters need to be escaped | |||
private static boolean gNeedEscaping[] = new boolean[128]; | |||
private static boolean[] gNeedEscaping = new boolean[128]; | |||
// the first hex character if a character needs to be escaped | |||
private static char gAfterEscaping1[] = new char[128]; | |||
private static char[] gAfterEscaping1 = new char[128]; | |||
// the second hex character if a character needs to be escaped | |||
private static char gAfterEscaping2[] = new char[128]; | |||
private static char[] gAfterEscaping2 = new char[128]; | |||
private static char[] gHexChs = {'0', '1', '2', '3', '4', '5', '6', '7', | |||
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; | |||
// initialize the above 3 arrays | |||
@@ -157,16 +157,18 @@ public final class Locator { | |||
// things when the path is not absolute, and fall back to the old parsing behavior. | |||
if (uriClazz != null && uri.startsWith("file:/")) { | |||
try { | |||
java.lang.reflect.Method createMethod = uriClazz.getMethod("create", new Class[] {String.class}); | |||
java.lang.reflect.Method createMethod | |||
= uriClazz.getMethod("create", new Class[] {String.class}); | |||
Object uriObj = createMethod.invoke(null, new Object[] {uri}); | |||
java.lang.reflect.Constructor fileConst = File.class.getConstructor(new Class[] {uriClazz}); | |||
File f = (File)fileConst.newInstance(new Object[] {uriObj}); | |||
java.lang.reflect.Constructor fileConst | |||
= File.class.getConstructor(new Class[] {uriClazz}); | |||
File f = (File) fileConst.newInstance(new Object[] {uriObj}); | |||
return f.getAbsolutePath(); | |||
} catch (java.lang.reflect.InvocationTargetException e) { | |||
Throwable e2 = e.getTargetException(); | |||
if (e2 instanceof IllegalArgumentException) { | |||
// Bad URI, pass this on. | |||
throw (IllegalArgumentException)e2; | |||
throw (IllegalArgumentException) e2; | |||
} else { | |||
// Unexpected target exception? Should not happen. | |||
e2.printStackTrace(); | |||
@@ -262,8 +264,9 @@ public final class Locator { | |||
for (; i < len; i++) { | |||
ch = path.charAt(i); | |||
// if it's not an ASCII character, break here, and use UTF-8 encoding | |||
if (ch >= 128) | |||
if (ch >= 128) { | |||
break; | |||
} | |||
if (gNeedEscaping[ch]) { | |||
if (sb == null) { | |||
sb = new StringBuffer(path.substring(0, i)); | |||
@@ -272,8 +275,7 @@ public final class Locator { | |||
sb.append(gAfterEscaping1[ch]); | |||
sb.append(gAfterEscaping2[ch]); | |||
// record the fact that it's escaped | |||
} | |||
else if (sb != null) { | |||
} else if (sb != null) { | |||
sb.append((char) ch); | |||
} | |||
} | |||
@@ -302,8 +304,7 @@ public final class Locator { | |||
sb.append('%'); | |||
sb.append(gAfterEscaping1[b]); | |||
sb.append(gAfterEscaping2[b]); | |||
} | |||
else { | |||
} else { | |||
sb.append((char) b); | |||
} | |||
} | |||
@@ -51,7 +51,7 @@ public class TimestampedLogger extends DefaultLogger { | |||
* @return The classic "BUILD SUCCESSFUL" | |||
*/ | |||
protected String getBuildSuccessfulMessage() { | |||
return super.getBuildSuccessfulMessage()+SPACER +getTimestamp(); | |||
return super.getBuildSuccessfulMessage() + SPACER + getTimestamp(); | |||
} | |||
protected String getTimestamp() { | |||
@@ -21,7 +21,7 @@ package org.apache.tools.ant.loader; | |||
import org.apache.tools.ant.AntClassLoader; | |||
/** | |||
* @deprecated since 1.7 | |||
* @deprecated since 1.7 | |||
* Just use {@link AntClassLoader} itself. | |||
*/ | |||
public class AntClassLoader2 extends AntClassLoader { | |||
@@ -22,7 +22,6 @@ import java.io.File; | |||
import java.util.Enumeration; | |||
import java.util.Vector; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.types.Environment; | |||
import org.apache.tools.ant.types.FileSet; | |||
@@ -84,7 +83,7 @@ public abstract class AbstractJarSignerTask extends Task { | |||
/** | |||
* Java declarations -J-Dname=value | |||
*/ | |||
private Environment sysProperties=new Environment(); | |||
private Environment sysProperties = new Environment(); | |||
/** | |||
* error string for unit test verification: {@value} | |||
@@ -98,7 +97,7 @@ public abstract class AbstractJarSignerTask extends Task { | |||
* @since Ant 1.7 | |||
*/ | |||
private Path path = null; | |||
/** | |||
* Set the maximum memory to be used by the jarsigner process | |||
* | |||
@@ -226,7 +225,7 @@ public abstract class AbstractJarSignerTask extends Task { | |||
*/ | |||
private RedirectorElement createRedirector() { | |||
RedirectorElement result = new RedirectorElement(); | |||
if(storepass!=null) { | |||
if (storepass != null) { | |||
StringBuffer input = new StringBuffer(storepass).append('\n'); | |||
if (keypass != null) { | |||
input.append(keypass).append('\n'); | |||
@@ -252,19 +251,19 @@ public abstract class AbstractJarSignerTask extends Task { | |||
*/ | |||
protected void setCommonOptions(final ExecTask cmd) { | |||
if (maxMemory != null) { | |||
addValue(cmd,"-J-Xmx" + maxMemory); | |||
addValue(cmd, "-J-Xmx" + maxMemory); | |||
} | |||
if (verbose) { | |||
addValue(cmd,"-verbose"); | |||
addValue(cmd, "-verbose"); | |||
} | |||
//now patch in all system properties | |||
Vector props=sysProperties.getVariablesVector(); | |||
Enumeration e=props.elements(); | |||
Vector props = sysProperties.getVariablesVector(); | |||
Enumeration e = props.elements(); | |||
while (e.hasMoreElements()) { | |||
Environment.Variable variable = (Environment.Variable) e.nextElement(); | |||
declareSysProperty(cmd,variable); | |||
declareSysProperty(cmd, variable); | |||
} | |||
} | |||
@@ -274,8 +273,9 @@ public abstract class AbstractJarSignerTask extends Task { | |||
* @param property property to set | |||
* @throws BuildException if the property is not correctly defined. | |||
*/ | |||
protected void declareSysProperty(ExecTask cmd,Environment.Variable property) { | |||
addValue(cmd, "-J-D"+property.getContent()); | |||
protected void declareSysProperty( | |||
ExecTask cmd, Environment.Variable property) { | |||
addValue(cmd, "-J-D" + property.getContent()); | |||
} | |||
@@ -286,7 +286,7 @@ public abstract class AbstractJarSignerTask extends Task { | |||
protected void bindToKeystore(final ExecTask cmd) { | |||
if (null != keystore) { | |||
// is the keystore a file | |||
addValue(cmd,"-keystore"); | |||
addValue(cmd, "-keystore"); | |||
String loc; | |||
File keystoreFile = getProject().resolveFile(keystore); | |||
if (keystoreFile.exists()) { | |||
@@ -323,7 +323,7 @@ public abstract class AbstractJarSignerTask extends Task { | |||
* @return a vector of FileSet instances | |||
*/ | |||
protected Vector createUnifiedSources() { | |||
Vector sources = (Vector)filesets.clone(); | |||
Vector sources = (Vector) filesets.clone(); | |||
if (jar != null) { | |||
//we create a fileset with the source file. | |||
//this lets us combine our logic for handling output directories, | |||
@@ -356,6 +356,7 @@ public abstract class AbstractJarSignerTask extends Task { | |||
/** | |||
* Has either a path or a fileset been specified? | |||
* @return true if a path or fileset has been specified. | |||
* @since Ant 1.7 | |||
*/ | |||
protected boolean hasResources() { | |||
@@ -362,9 +362,9 @@ public class Ant extends Task { | |||
+ "its own parent target."); | |||
} | |||
boolean circular = false; | |||
for (Iterator it = locals.iterator(); | |||
for (Iterator it = locals.iterator(); | |||
!circular && it.hasNext();) { | |||
Target other = | |||
Target other = | |||
(Target) (getProject().getTargets().get(it.next())); | |||
circular |= (other != null | |||
&& other.dependsOn(owningTargetName)); | |||
@@ -381,7 +381,7 @@ public class Ant extends Task { | |||
addReferences(); | |||
if (locals.size() > 0 && !(locals.size() == 1 | |||
if (locals.size() > 0 && !(locals.size() == 1 | |||
&& "".equals(locals.get(0)))) { | |||
BuildException be = null; | |||
try { | |||
@@ -46,7 +46,8 @@ import org.apache.tools.ant.types.Reference; | |||
*/ | |||
public class AntStructure extends Task { | |||
private static final String lSep = System.getProperty("line.separator"); | |||
private static final String LINE_SEP | |||
= System.getProperty("line.separator"); | |||
private File output; | |||
private StructurePrinter printer = new DTDPrinter(); | |||
@@ -61,6 +62,7 @@ public class AntStructure extends Task { | |||
/** | |||
* The StructurePrinter to use. | |||
* @param p the printer to use. | |||
* @since Ant 1.7 | |||
*/ | |||
public void add(StructurePrinter p) { | |||
@@ -101,8 +103,9 @@ public class AntStructure extends Task { | |||
Enumeration dataTypes = getProject().getDataTypeDefinitions().keys(); | |||
while (dataTypes.hasMoreElements()) { | |||
String typeName = (String) dataTypes.nextElement(); | |||
printer.printElementDecl(out, getProject(), typeName, | |||
(Class) getProject().getDataTypeDefinitions().get(typeName)); | |||
printer.printElementDecl( | |||
out, getProject(), typeName, | |||
(Class) getProject().getDataTypeDefinitions().get(typeName)); | |||
} | |||
Enumeration tasks = getProject().getTaskDefinitions().keys(); | |||
@@ -282,11 +285,11 @@ public class AntStructure extends Task { | |||
sb.append(name).append(" "); | |||
if (org.apache.tools.ant.types.Reference.class.equals(element)) { | |||
sb.append("EMPTY>").append(lSep); | |||
sb.append("EMPTY>").append(LINE_SEP); | |||
sb.append("<!ATTLIST ").append(name); | |||
sb.append(lSep).append(" id ID #IMPLIED"); | |||
sb.append(lSep).append(" refid IDREF #IMPLIED"); | |||
sb.append(">").append(lSep); | |||
sb.append(LINE_SEP).append(" id ID #IMPLIED"); | |||
sb.append(LINE_SEP).append(" refid IDREF #IMPLIED"); | |||
sb.append(">").append(LINE_SEP); | |||
out.println(sb); | |||
return; | |||
} | |||
@@ -326,7 +329,7 @@ public class AntStructure extends Task { | |||
sb = new StringBuffer("<!ATTLIST "); | |||
sb.append(name); | |||
sb.append(lSep).append(" id ID #IMPLIED"); | |||
sb.append(LINE_SEP).append(" id ID #IMPLIED"); | |||
e = ih.getAttributes(); | |||
while (e.hasMoreElements()) { | |||
@@ -335,7 +338,8 @@ public class AntStructure extends Task { | |||
continue; | |||
} | |||
sb.append(lSep).append(" ").append(attrName).append(" "); | |||
sb.append(LINE_SEP).append(" ") | |||
.append(attrName).append(" "); | |||
Class type = ih.getAttributeType(attrName); | |||
if (type.equals(java.lang.Boolean.class) | |||
|| type.equals(java.lang.Boolean.TYPE)) { | |||
@@ -371,7 +375,7 @@ public class AntStructure extends Task { | |||
} | |||
sb.append("#IMPLIED"); | |||
} | |||
sb.append(">").append(lSep); | |||
sb.append(">").append(LINE_SEP); | |||
out.println(sb); | |||
final int count = v.size(); | |||
@@ -51,7 +51,7 @@ public class Apt | |||
/** A warning message if used with java < 1.5. */ | |||
public static final String ERROR_WRONG_JAVA_VERSION | |||
= "Apt task requires Java 1.5+"; | |||
/** | |||
* exposed for debug messages | |||
*/ | |||
@@ -140,7 +140,7 @@ public class Apt | |||
*/ | |||
public void setFork(boolean fork) { | |||
if (!fork) { | |||
log(WARNING_IGNORING_FORK,Project.MSG_WARN); | |||
log(WARNING_IGNORING_FORK, Project.MSG_WARN); | |||
} | |||
} | |||
@@ -173,7 +173,7 @@ public class Available extends Task implements Condition { | |||
} | |||
/** | |||
* @deprecated since 1.5.x. | |||
* @deprecated since 1.5.x. | |||
* setType(String) is deprecated and is replaced with | |||
* setType(Available.FileDir) to make Ant's Introspection | |||
* mechanism do the work and also to encapsulate operations on | |||
@@ -100,7 +100,7 @@ public class BUnzip2 extends Unpack { | |||
* support non-file resources needs to override this method. We | |||
* need to do so for backwards compatibility reasons since we | |||
* can't expect subclasses to support resources.</p> | |||
* | |||
* @return true if this class supports non file resources. | |||
* @since Ant 1.7 | |||
*/ | |||
protected boolean supportsNonFileResources() { | |||
@@ -61,7 +61,7 @@ public class BZip2 extends Pack { | |||
* support non-file resources needs to override this method. We | |||
* need to do so for backwards compatibility reasons since we | |||
* can't expect subclasses to support resources.</p> | |||
* | |||
* @return true if this task support non file resources. | |||
* @since Ant 1.7 | |||
*/ | |||
protected boolean supportsNonFileResources() { | |||
@@ -449,13 +449,13 @@ public class Checksum extends MatchingTask implements Condition { | |||
if (todir != null) { | |||
// A separate directory was explicitly declared | |||
String path = (String) relativeFilePaths.get(file); | |||
if(path==null) { | |||
if (path == null) { | |||
//bug 37386. this should not occur, but it has, once. | |||
throw new BuildException("Internal error: " + | |||
"relativeFilePaths could not match file"+ | |||
file+ | |||
"\n" + | |||
"please file a bug report on this"); | |||
throw new BuildException( | |||
"Internal error: " | |||
+ "relativeFilePaths could not match file" | |||
+ file + "\n" | |||
+ "please file a bug report on this"); | |||
} | |||
directory = new File(todir, path).getParentFile(); | |||
// Create the directory, as it might not exist. | |||
@@ -631,7 +631,7 @@ public class Checksum extends MatchingTask implements Condition { | |||
} catch (ParseException e) { | |||
throw new BuildException("Couldn't read checksum file " + f, e); | |||
} finally { | |||
FileUtils.close(diskChecksumReader); | |||
FileUtils.close(diskChecksumReader); | |||
} | |||
} | |||
@@ -432,8 +432,9 @@ public class Concat extends Task { | |||
if (!outofdate) { | |||
for (Iterator i = existRc.iterator(); !outofdate && i.hasNext();) { | |||
Resource r = (Resource) i.next(); | |||
outofdate = (r.getLastModified() == 0L || | |||
r.getLastModified() > destinationFile.lastModified()); | |||
outofdate = | |||
(r.getLastModified() == 0L | |||
|| r.getLastModified() > destinationFile.lastModified()); | |||
} | |||
} | |||
if (!outofdate) { | |||
@@ -493,6 +494,7 @@ public class Concat extends Task { | |||
try { | |||
t.join(); | |||
} catch (InterruptedException ee) { | |||
// Empty | |||
} | |||
} | |||
} finally { | |||
@@ -156,7 +156,7 @@ public class Copy extends Task { | |||
/** | |||
* Give the copied files the same last modified time as the original files. | |||
* @param preserve a boolean string. | |||
* @deprecated since 1.5.x. | |||
* @deprecated since 1.5.x. | |||
* setPreserveLastModified(String) has been deprecated and | |||
* replaced with setPreserveLastModified(boolean) to | |||
* consistently let the Introspection mechanism work. | |||
@@ -289,7 +289,7 @@ public class Copy extends Task { | |||
public void addFileset(FileSet set) { | |||
add(set); | |||
} | |||
/** | |||
* Add a collection of files to copy. | |||
* @param res a resource collection to copy. | |||
@@ -298,7 +298,7 @@ public class Copy extends Task { | |||
public void add(ResourceCollection res) { | |||
rcs.add(res); | |||
} | |||
/** | |||
* Define the mapper to map source to destination files. | |||
* @return a mapper to be configured. | |||
@@ -423,7 +423,7 @@ public class Copy extends Task { | |||
/* for historical and performance reasons we have to do | |||
things in a rather complex way. | |||
(1) Move is optimized to move directories if a fileset | |||
has been included completely, therefore FileSets need a | |||
special treatment. This is also required to support | |||
@@ -498,7 +498,7 @@ public class Copy extends Task { | |||
// files. | |||
if (r.isDirectory() || r instanceof FileResource) { | |||
add(baseDir, name, | |||
r.isDirectory() ? dirsByBasedir | |||
r.isDirectory() ? dirsByBasedir | |||
: filesByBasedir); | |||
baseDirs.add(baseDir); | |||
} else { // a not-directory file resource | |||
@@ -912,7 +912,7 @@ public class Copy extends Task { | |||
* support non-file resources needs to override this method. We | |||
* need to do so for backwards compatibility reasons since we | |||
* can't expect subclasses to support resources.</p> | |||
* | |||
* @return true if this task supports non file resources. | |||
* @since Ant 1.7 | |||
*/ | |||
protected boolean supportsNonFileResources() { | |||
@@ -977,7 +977,7 @@ public class Copy extends Task { | |||
private String getMessage(Exception ex) { | |||
return ex.getMessage() == null ? ex.toString() : ex.getMessage(); | |||
} | |||
/** | |||
* Returns a reason for failure based on | |||
* the exception thrown. | |||
@@ -31,9 +31,9 @@ import java.io.IOException; | |||
/** | |||
* Copy the contents of a path to a destination, using the mapper of choice | |||
* | |||
* | |||
* @since Ant 1.7 | |||
* | |||
* | |||
* @ant.task category="filesystem" | |||
*/ | |||
@@ -69,8 +69,8 @@ public class CopyPath extends Task { | |||
/** | |||
* add a mapper | |||
* | |||
* @param newmapper | |||
* | |||
* @param newmapper the mapper to add. | |||
*/ | |||
public void add(FileNameMapper newmapper) { | |||
if (mapper != null) { | |||
@@ -81,7 +81,7 @@ public class CopyPath extends Task { | |||
/** | |||
* Set the path to be used when running the Java class. | |||
* | |||
* | |||
* @param s | |||
* an Ant Path object containing the path. | |||
*/ | |||
@@ -91,7 +91,7 @@ public class CopyPath extends Task { | |||
/** | |||
* Set the path to use by reference. | |||
* | |||
* | |||
* @param r | |||
* a reference to an existing path. | |||
*/ | |||
@@ -101,7 +101,7 @@ public class CopyPath extends Task { | |||
/** | |||
* Create a path. | |||
* | |||
* | |||
* @return a path to be configured. | |||
*/ | |||
public Path createPath() { | |||
@@ -122,7 +122,7 @@ public class CopyPath extends Task { | |||
/** | |||
* Ensure we have a consistent and legal set of attributes, and set any | |||
* internal flags necessary based on different combinations of attributes. | |||
* | |||
* | |||
* @throws BuildException | |||
* if an error occurs. | |||
*/ | |||
@@ -140,7 +140,7 @@ public class CopyPath extends Task { | |||
/** | |||
* This is a very minimal derivative of the nomal copy logic. | |||
* | |||
* | |||
* @throws BuildException | |||
* if something goes wrong with the build. | |||
*/ | |||
@@ -38,7 +38,7 @@ public abstract class DefBase extends AntlibDefinition { | |||
/** | |||
* @param reverseLoader if true a delegated loader will take precedence over | |||
* the parent | |||
* @deprecated since 1.6.x. | |||
* @deprecated since 1.6.x. | |||
* stop using this attribute | |||
* @ant.attribute ignore="true" | |||
*/ | |||
@@ -290,7 +290,8 @@ public abstract class Definer extends DefBase { | |||
/** | |||
* This is where the logic to map from a URI to an antlib resource | |||
* is kept. | |||
* is kept. | |||
* @param uri the xml namespace uri that to convert. | |||
* @return the name of a resource. It may not exist | |||
*/ | |||
@@ -298,8 +299,8 @@ public abstract class Definer extends DefBase { | |||
String path = uri.substring(MagicNames.ANTLIB_PREFIX.length()); | |||
String resource; | |||
if (path.startsWith("//")) { | |||
//handle new style full paths to an antlib, in which | |||
//all but the forward slashes are allowed. | |||
//handle new style full paths to an antlib, in which | |||
//all but the forward slashes are allowed. | |||
resource = path.substring("//".length()); | |||
if (!resource.endsWith(".xml")) { | |||
//if we haven't already named an XML file, it gets antlib.xml | |||
@@ -313,11 +314,11 @@ public abstract class Definer extends DefBase { | |||
} | |||
/** | |||
* Convert a file to a file: URL. | |||
* | |||
* Convert a file to a file: URL. | |||
* | |||
* @return the URL, or null if it isn't valid and the active error policy | |||
* is not to raise a fault | |||
* @throws BuildException if the file is missing/not a file and the | |||
* @throws BuildException if the file is missing/not a file and the | |||
* policy requires failure at this point. | |||
*/ | |||
private URL fileToURL() { | |||
@@ -480,7 +481,7 @@ public abstract class Definer extends DefBase { | |||
"Invalid antlib attribute - it must start with antlib:"); | |||
} | |||
setURI(antlib); | |||
this.resource = antlib.substring("antlib:".length()).replace('.','/') | |||
this.resource = antlib.substring("antlib:".length()).replace('.', '/') | |||
+ "/antlib.xml"; | |||
definerSet = true; | |||
} | |||
@@ -600,10 +600,10 @@ public class Delete extends MatchingTask { | |||
} catch (Exception e) { | |||
handle(e); | |||
} finally { | |||
if (implicit != null) { | |||
filesets.remove(implicit); | |||
} | |||
} | |||
if (implicit != null) { | |||
filesets.remove(implicit); | |||
} | |||
} | |||
} | |||
//************************************************************************ | |||
@@ -693,7 +693,7 @@ public class Delete extends MatchingTask { | |||
+ d.getAbsolutePath(), quiet ? Project.MSG_VERBOSE : verbosity); | |||
for (int j = 0; j < files.length; j++) { | |||
File f = new File(d, files[j]); | |||
log("Deleting " + f.getAbsolutePath(), | |||
log("Deleting " + f.getAbsolutePath(), | |||
quiet ? Project.MSG_VERBOSE : verbosity); | |||
if (!delete(f)) { | |||
handle("Unable to delete file " + f.getAbsolutePath()); | |||
@@ -707,7 +707,7 @@ public class Delete extends MatchingTask { | |||
File currDir = new File(d, dirs[j]); | |||
String[] dirFiles = currDir.list(); | |||
if (dirFiles == null || dirFiles.length == 0) { | |||
log("Deleting " + currDir.getAbsolutePath(), | |||
log("Deleting " + currDir.getAbsolutePath(), | |||
quiet ? Project.MSG_VERBOSE : verbosity); | |||
if (!delete(currDir)) { | |||
handle("Unable to delete directory " | |||
@@ -722,7 +722,7 @@ public class Delete extends MatchingTask { | |||
log("Deleted " | |||
+ dirCount | |||
+ " director" + (dirCount == 1 ? "y" : "ies") | |||
+ " form " + d.getAbsolutePath(), | |||
+ " form " + d.getAbsolutePath(), | |||
quiet ? Project.MSG_VERBOSE : verbosity); | |||
} | |||
} | |||
@@ -1,9 +1,3 @@ | |||
package org.apache.tools.ant.taskdefs; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.Diagnostics; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||
* contributor license agreements. See the NOTICE file distributed with | |||
@@ -21,6 +15,12 @@ import org.apache.tools.ant.Diagnostics; | |||
* limitations under the License. | |||
* | |||
*/ | |||
package org.apache.tools.ant.taskdefs; | |||
import org.apache.tools.ant.Task; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.Diagnostics; | |||
/** | |||
* This is a task that hands off work to the Diagnostics module. | |||
@@ -28,10 +28,10 @@ import org.apache.tools.ant.Diagnostics; | |||
*/ | |||
public class DiagnosticsTask extends Task { | |||
private static final String[] args=new String[0]; | |||
private static final String[] ARGS = new String[0]; | |||
public void execute() throws BuildException { | |||
Diagnostics.main(args); | |||
Diagnostics.main(ARGS); | |||
} | |||
@@ -50,7 +50,7 @@ public class Ear extends Jar { | |||
/** | |||
* Set the destination file. | |||
* @param earFile the destination file | |||
* @deprecated since 1.5.x. | |||
* @deprecated since 1.5.x. | |||
* Use setDestFile(destfile) instead. | |||
*/ | |||
public void setEarfile(File earFile) { | |||
@@ -61,12 +61,12 @@ public class Echo extends Task { | |||
Writer out = null; | |||
try { | |||
String filename = file.getAbsolutePath(); | |||
if(encoding==null || encoding.length()==0) { | |||
if(encoding == null || encoding.length() == 0) { | |||
out = new FileWriter(filename, append); | |||
} else { | |||
out = new BufferedWriter( | |||
new OutputStreamWriter( | |||
new FileOutputStream(filename, append),encoding)); | |||
new FileOutputStream(filename, append), encoding)); | |||
} | |||
out.write(message, 0, message.length()); | |||
} catch (IOException ioe) { | |||
@@ -132,7 +132,7 @@ public class Echo extends Task { | |||
/** | |||
* Declare the encoding to use when outputting to a file; | |||
* Use "" for the platform's default encoding. | |||
* @param encoding | |||
* @param encoding the character encoding to use. | |||
* @since 1.7 | |||
*/ | |||
public void setEncoding(String encoding) { | |||
@@ -39,7 +39,7 @@ import org.apache.tools.ant.Task; | |||
* dead code by the Ant developers and is unmaintained. Don't use | |||
* it.</strong></p> | |||
* | |||
* @deprecated since 1.2. | |||
* @deprecated since 1.2. | |||
* delegate to {@link org.apache.tools.ant.taskdefs.Execute Execute} | |||
* instead. | |||
*/ | |||
@@ -388,7 +388,7 @@ public class ExecTask extends Task { | |||
/** | |||
* Restrict this execution to a single OS Family | |||
* @param osFamily | |||
* @param osFamily the family to restrict to. | |||
*/ | |||
public void setOsFamily(String osFamily) { | |||
this.osFamily = osFamily.toLowerCase(Locale.US); | |||
@@ -543,7 +543,7 @@ public class ExecTask extends Task { | |||
*/ | |||
protected boolean isValidOs() { | |||
//hand osfamily off to Os class, if set | |||
if(osFamily!=null && !Os.isOs(osFamily,null,null,null)) { | |||
if (osFamily != null && !Os.isOs(osFamily, null, null, null)) { | |||
return false; | |||
} | |||
//the Exec OS check is different from Os.isOs(), which | |||
@@ -49,7 +49,7 @@ import org.apache.tools.ant.util.StringUtils; | |||
*/ | |||
public class Execute { | |||
/** Invalid exit code. | |||
/** Invalid exit code. | |||
* set to {@link Integer#MAX_VALUE} | |||
*/ | |||
public static final int INVALID = Integer.MAX_VALUE; | |||
@@ -1033,8 +1033,8 @@ public class Execute { | |||
throw new IOException("Cannot locate antRun script: " | |||
+ "Property '" + MagicNames.ANT_HOME + "' not found"); | |||
} | |||
String antRun = | |||
FILE_UTILS.resolveFile(project.getBaseDir(), | |||
String antRun = | |||
FILE_UTILS.resolveFile(project.getBaseDir(), | |||
antHome + File.separator + myScript).toString(); | |||
// Build the command | |||
@@ -1092,8 +1092,8 @@ public class Execute { | |||
throw new IOException("Cannot locate antRun script: " | |||
+ "Property '" + MagicNames.ANT_HOME + "' not found"); | |||
} | |||
String antRun = | |||
FILE_UTILS.resolveFile(project.getBaseDir(), | |||
String antRun = | |||
FILE_UTILS.resolveFile(project.getBaseDir(), | |||
antHome + File.separator + myScript).toString(); | |||
// Build the command | |||
@@ -1210,8 +1210,7 @@ public class Execute { | |||
public void run() { | |||
try { | |||
p.waitFor(); | |||
} | |||
catch (InterruptedException e) { | |||
} catch (InterruptedException e) { | |||
//ignore | |||
} | |||
FileUtils.delete(f); | |||
@@ -92,7 +92,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { | |||
* Set the stream to which all output (System.out as well as System.err) | |||
* will be written. | |||
* @param out the PrintStream where output should be sent. | |||
* @deprecated since 1.4.x. | |||
* @deprecated since 1.4.x. | |||
* manage output at the task level. | |||
*/ | |||
public void setOutput(PrintStream out) { | |||
@@ -417,7 +417,7 @@ public class ExecuteOn extends ExecTask { | |||
baseDirs.removeAllElements(); | |||
} | |||
} | |||
if (resources != null) { | |||
Iterator iter = resources.iterator(); | |||
while (iter.hasNext()) { | |||
@@ -69,7 +69,7 @@ public class ExecuteWatchdog implements TimeoutObserver { | |||
/** | |||
* @see #ExecuteWatchdog(long) | |||
* @deprecated since 1.5.x. | |||
* @deprecated since 1.5.x. | |||
* Use constructor with a long type instead. | |||
* (1.4.x compatibility) | |||
*/ | |||
@@ -174,7 +174,7 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||
* <li>remove: remove all CR characters | |||
* </ul> | |||
* | |||
* @deprecated since 1.4.x. | |||
* @deprecated since 1.4.x. | |||
* Use {@link #setEol setEol} instead. | |||
*/ | |||
public void setCr(AddAsisRemove attr) { | |||
@@ -277,7 +277,7 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||
public void execute() throws BuildException { | |||
// first off, make sure that we've got a srcdir and destdir | |||
validate(); | |||
// log options used | |||
String enc = encoding == null ? "default" : encoding; | |||
log("options:" | |||
@@ -326,7 +326,7 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||
} | |||
} | |||
} | |||
private void processFile(String file) throws BuildException { | |||
File srcFile = new File(srcDir, file); | |||
long lastModified = srcFile.lastModified(); | |||
@@ -58,7 +58,7 @@ public class GZip extends Pack { | |||
* support non-file resources needs to override this method. We | |||
* need to do so for backwards compatibility reasons since we | |||
* can't expect subclasses to support resources.</p> | |||
* | |||
* @return true if this case supports non file resources. | |||
* @since Ant 1.7 | |||
*/ | |||
protected boolean supportsNonFileResources() { | |||
@@ -339,9 +339,9 @@ public class Get extends Task { | |||
/** | |||
* Provide this for Backward Compatibility. | |||
*/ | |||
protected static class Base64Converter | |||
extends org.apache.tools.ant.util.Base64Converter {} | |||
extends org.apache.tools.ant.util.Base64Converter { | |||
} | |||
public interface DownloadProgress { | |||
/** | |||
@@ -94,12 +94,12 @@ public class ImportTask extends Task { | |||
ProjectHelper helper = | |||
(ProjectHelper) getProject(). | |||
getReference(ProjectHelper.PROJECTHELPER_REFERENCE); | |||
if (helper == null) { | |||
// this happens if the projecthelper was not registered with the project. | |||
throw new BuildException("import requires support in ProjectHelper"); | |||
} | |||
Vector importStack = helper.getImportStack(); | |||
if (importStack.size() == 0) { | |||
@@ -147,7 +147,7 @@ public class Jar extends Zip { | |||
private ZipExtraField[] JAR_MARKER = new ZipExtraField[] { | |||
JarMarker.getInstance() | |||
}; | |||
protected String emptyBehavior = "create"; | |||
/** constructor */ | |||
@@ -183,7 +183,6 @@ public class Jar extends Zip { | |||
emptyBehavior = we.getValue(); | |||
} | |||
/** | |||
* Set the destination file. | |||
* @param jarFile the destination file | |||
@@ -390,12 +389,12 @@ public class Jar extends Zip { | |||
private void writeServices(ZipOutputStream zOut) throws IOException { | |||
Iterator serviceIterator; | |||
Service service; | |||
serviceIterator = serviceList.iterator(); | |||
while(serviceIterator.hasNext()){ | |||
while(serviceIterator.hasNext()) { | |||
service = (Service) serviceIterator.next(); | |||
//stolen from writeManifest | |||
super.zipFile(service.getAsStream(), zOut, | |||
super.zipFile(service.getAsStream(), zOut, | |||
"META-INF/service/" + service.getType(), | |||
System.currentTimeMillis(), null, | |||
ZipFileSet.DEFAULT_FILE_MODE); | |||
@@ -708,7 +707,8 @@ public class Jar extends Zip { | |||
} | |||
} | |||
} catch (Throwable t) { | |||
log("error while reading original manifest in file: " + zipFile.toString() + t.getMessage(), | |||
log("error while reading original manifest in file: " | |||
+ zipFile.toString() + t.getMessage(), | |||
Project.MSG_WARN); | |||
needsUpdate = true; | |||
} | |||
@@ -744,7 +744,7 @@ public class Jar extends Zip { | |||
+ ": no files were included.", | |||
getLocation()); | |||
} | |||
ZipOutputStream zOut = null; | |||
try { | |||
log("Building MANIFEST-only jar: " | |||
@@ -138,7 +138,8 @@ public class Java extends Task { | |||
throw new BuildException("Cannot spawn a java process in non-forked mode." | |||
+ " Please set fork='true'. "); | |||
} | |||
if (getCommandLine().getClasspath()!=null && getCommandLine().getJar()!=null) { | |||
if (getCommandLine().getClasspath() != null | |||
&& getCommandLine().getJar() != null) { | |||
log("When using 'jar' attribute classpath-settings are ignored. " | |||
+ "See the manual for more information.", Project.MSG_VERBOSE); | |||
} | |||
@@ -933,4 +934,4 @@ public class Java extends Task { | |||
public CommandlineJava.SysProperties getSysProperties() { | |||
return getCommandLine().getSystemProperties(); | |||
} | |||
} | |||
} |
@@ -28,7 +28,6 @@ import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter; | |||
import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory; | |||
import org.apache.tools.ant.types.Path; | |||
import org.apache.tools.ant.types.Reference; | |||
import org.apache.tools.ant.util.FileUtils; | |||
import org.apache.tools.ant.util.GlobPatternMapper; | |||
import org.apache.tools.ant.util.JavaEnvUtils; | |||
import org.apache.tools.ant.util.SourceFileScanner; | |||
@@ -34,7 +34,7 @@ import org.apache.tools.ant.Task; | |||
* by the Ant developers and is unmaintained. Don't use | |||
* it.</strong></p> | |||
* | |||
* @deprecated since 1.2. | |||
* @deprecated since 1.2. | |||
* Use Jikes' exit value to detect compilation failure. | |||
*/ | |||
public class JikesOutputParser implements ExecuteStreamHandler { | |||
@@ -133,7 +133,7 @@ public class LoadResource extends Task { | |||
try { | |||
final long len = src.getSize(); | |||
log("resource size = " | |||
+ (len != Resource.UNKNOWN_SIZE ? String.valueOf(len) | |||
+ (len != Resource.UNKNOWN_SIZE ? String.valueOf(len) | |||
: "unknown"), Project.MSG_DEBUG); | |||
//discard most of really big resources | |||
final int size = (int) len; | |||
@@ -84,6 +84,7 @@ public class LogOutputStream extends LineOrientedOutputStream { | |||
* Logs a line to the log system of ant. | |||
* | |||
* @param line the line to log. | |||
* @param level the logging level to use. | |||
*/ | |||
protected void processLine(String line, int level) { | |||
pc.log(line, level); | |||
@@ -93,4 +94,4 @@ public class LogOutputStream extends LineOrientedOutputStream { | |||
return level; | |||
} | |||
} | |||
} |
@@ -345,7 +345,7 @@ public class MacroDef extends AntlibDefinition { | |||
getProject()); | |||
helper.addDataTypeDefinition(def); | |||
log("creating macro " + name,Project.MSG_VERBOSE); | |||
log("creating macro " + name, Project.MSG_VERBOSE); | |||
} | |||
/** | |||
@@ -426,7 +426,7 @@ public class MacroDef extends AntlibDefinition { | |||
* @return a <code>boolean</code> value | |||
*/ | |||
protected boolean equals(Member m) { | |||
return (name == null)? m.name == null: name.equals(m.name); | |||
return (name == null) ? m.name == null : name.equals(m.name); | |||
} | |||
/** | |||
@@ -576,7 +576,7 @@ public class MacroDef extends AntlibDefinition { | |||
* This is not allowed for the define nested element. | |||
* | |||
* @param defaultValue not used | |||
* @throws BuildException, always | |||
* @throws BuildException always | |||
*/ | |||
public void setDefault(String defaultValue) { | |||
throw new BuildException( | |||
@@ -585,7 +585,7 @@ public class MacroDef extends AntlibDefinition { | |||
/** | |||
* Gets the default value for this attibute. | |||
* | |||
* | |||
* @return the generated <em>unique</em> name, of the form | |||
* "prefix#this classname#<aCounter>". | |||
*/ | |||
@@ -86,7 +86,7 @@ public class Manifest { | |||
/** Encoding to be used for JAR files. */ | |||
public static final String JAR_ENCODING = "UTF-8"; | |||
/** | |||
* An attribute for the manifest. | |||
* Those attributes that are not nested into a section will be added to the "Main" section. | |||
@@ -105,7 +105,7 @@ public class Manifest { | |||
* In this case the first line will have 74 bytes total line length | |||
* (including CRLF). This conflicts with the 72 bytes total line length | |||
* max, but is the only possible conclusion from the manifest specification, if | |||
* names with 70 bytes length are allowed, have to be on the first line, and | |||
* names with 70 bytes length are allowed, have to be on the first line, and | |||
* have to be followed by ": ". | |||
*/ | |||
private static final int MAX_NAME_LENGTH = 70; | |||
@@ -326,25 +326,20 @@ public class Manifest { | |||
throws IOException { | |||
String line = null; | |||
int nameLength = name.getBytes(JAR_ENCODING).length; | |||
if (nameLength > MAX_NAME_VALUE_LENGTH) | |||
{ | |||
if (nameLength > MAX_NAME_LENGTH) | |||
{ | |||
if (nameLength > MAX_NAME_VALUE_LENGTH) { | |||
if (nameLength > MAX_NAME_LENGTH) { | |||
throw new IOException("Unable to write manifest line " | |||
+ name + ": " + value); | |||
} | |||
writer.print(name + ": " + EOL); | |||
line = " " + value; | |||
} | |||
else | |||
{ | |||
} else { | |||
line = name + ": " + value; | |||
} | |||
while (line.getBytes(JAR_ENCODING).length > MAX_SECTION_LENGTH) { | |||
// try to find a MAX_LINE_LENGTH byte section | |||
int breakIndex = MAX_SECTION_LENGTH; | |||
if (breakIndex >= line.length()) | |||
{ | |||
if (breakIndex >= line.length()) { | |||
breakIndex = line.length() - 1; | |||
} | |||
String section = line.substring(0, breakIndex); | |||
@@ -36,16 +36,16 @@ import org.apache.tools.ant.util.FileUtils; | |||
public class ManifestClassPath extends Task { | |||
/** The property name to hold the classpath value. */ | |||
private String _name; | |||
private String name; | |||
/** The directory the classpath will be relative from. */ | |||
private File _dir; | |||
private File dir; | |||
/** The maximum parent directory level to traverse. */ | |||
private int _maxParentLevels = 2; | |||
private int maxParentLevels = 2; | |||
/** The classpath to convert. */ | |||
private Path _path; | |||
private Path path; | |||
/** | |||
* Sets a property, which must not already exist, with a space | |||
@@ -53,37 +53,37 @@ public class ManifestClassPath extends Task { | |||
* file's parent directory. | |||
*/ | |||
public void execute() { | |||
if (_name == null) { | |||
if (name == null) { | |||
throw new BuildException("Missing 'property' attribute!"); | |||
} | |||
if (_dir == null) { | |||
if (dir == null) { | |||
throw new BuildException("Missing 'jarfile' attribute!"); | |||
} | |||
if (getProject().getProperty(_name) != null) { | |||
throw new BuildException("Property '" + _name + "' already set!"); | |||
if (getProject().getProperty(name) != null) { | |||
throw new BuildException("Property '" + name + "' already set!"); | |||
} | |||
if (_path == null) { | |||
if (path == null) { | |||
throw new BuildException("Missing nested <classpath>!"); | |||
} | |||
// Normalize the reference directory (containing the jar) | |||
final FileUtils fileUtils = FileUtils.getFileUtils(); | |||
_dir = fileUtils.normalize(_dir.getAbsolutePath()); | |||
dir = fileUtils.normalize(dir.getAbsolutePath()); | |||
// Create as many directory prefixes as parent levels to traverse, | |||
// in addition to the reference directory itself | |||
File currDir = _dir; | |||
String[] dirs = new String[_maxParentLevels + 1]; | |||
for (int i = 0; i < _maxParentLevels + 1; ++i) { | |||
File currDir = dir; | |||
String[] dirs = new String[maxParentLevels + 1]; | |||
for (int i = 0; i < maxParentLevels + 1; ++i) { | |||
dirs[i] = currDir.getAbsolutePath() + File.separatorChar; | |||
currDir = currDir.getParentFile(); | |||
if (currDir == null) { | |||
_maxParentLevels = i + 1; | |||
maxParentLevels = i + 1; | |||
break; | |||
} | |||
} | |||
String[] elements = _path.list(); | |||
String[] elements = path.list(); | |||
StringBuffer buffer = new StringBuffer(); | |||
StringBuffer element = new StringBuffer(); | |||
for (int i = 0; i < elements.length; ++i) { | |||
@@ -95,7 +95,7 @@ public class ManifestClassPath extends Task { | |||
// Find the longest prefix shared by the current file | |||
// and the reference directory. | |||
String relPath = null; | |||
for (int j = 0; j <= _maxParentLevels; ++j) { | |||
for (int j = 0; j <= maxParentLevels; ++j) { | |||
String dir = dirs[j]; | |||
if (!fullPath.startsWith(dir)) { | |||
continue; | |||
@@ -115,8 +115,9 @@ public class ManifestClassPath extends Task { | |||
// No match, so bail out! | |||
if (relPath == null) { | |||
throw new BuildException("No suitable relative path from " + | |||
_dir + " to " + fullPath); | |||
throw new BuildException( | |||
"No suitable relative path from " | |||
+ dir + " to " + fullPath); | |||
} | |||
// Manifest's ClassPath: attribute always uses forward | |||
@@ -138,7 +139,7 @@ public class ManifestClassPath extends Task { | |||
} | |||
// Finally assign the property with the manifest classpath | |||
getProject().setNewProperty(_name, buffer.toString().trim()); | |||
getProject().setNewProperty(name, buffer.toString().trim()); | |||
} | |||
/** | |||
@@ -147,7 +148,7 @@ public class ManifestClassPath extends Task { | |||
* @param name the property name | |||
*/ | |||
public void setProperty(String name) { | |||
_name = name; | |||
this.name = name; | |||
} | |||
/** | |||
@@ -161,7 +162,7 @@ public class ManifestClassPath extends Task { | |||
if (!parent.isDirectory()) { | |||
throw new BuildException("Jar's directory not found: " + parent); | |||
} | |||
_dir = parent; | |||
this.dir = parent; | |||
} | |||
/** | |||
@@ -171,7 +172,7 @@ public class ManifestClassPath extends Task { | |||
* @param levels the max level. Defaults to 2. | |||
*/ | |||
public void setMaxParentLevels(int levels) { | |||
_maxParentLevels = levels; | |||
this.maxParentLevels = levels; | |||
} | |||
/** | |||
@@ -180,7 +181,7 @@ public class ManifestClassPath extends Task { | |||
* @param path the classpath to convert. | |||
*/ | |||
public void addClassPath(Path path) { | |||
_path = path; | |||
this.path = path; | |||
} | |||
} |
@@ -65,7 +65,8 @@ public class Mkdir extends Task { | |||
} | |||
log("Created dir: " + dir.getAbsolutePath()); | |||
} else { | |||
log("Skipping " + dir.getAbsolutePath() + " because it already exists.", Project.MSG_VERBOSE); | |||
log("Skipping " + dir.getAbsolutePath() | |||
+ " because it already exists.", Project.MSG_VERBOSE); | |||
} | |||
} | |||
@@ -183,7 +183,7 @@ public abstract class Pack extends Task { | |||
/** | |||
* The source resource. | |||
* | |||
* @return the source. | |||
* @since Ant 1.7 | |||
*/ | |||
public Resource getSrcResource() { | |||
@@ -194,7 +194,7 @@ public abstract class Pack extends Task { | |||
* Whether this task can deal with non-file resources. | |||
* | |||
* <p>This implementation returns false.</p> | |||
* | |||
* @return false. | |||
* @since Ant 1.7 | |||
*/ | |||
protected boolean supportsNonFileResources() { | |||
@@ -96,7 +96,7 @@ public class PreSetDef extends AntlibDefinition implements TaskContainer { | |||
newDef.setName(name); | |||
helper.addDataTypeDefinition(newDef); | |||
log("defining preset "+name,Project.MSG_VERBOSE); | |||
log("defining preset " + name, Project.MSG_VERBOSE); | |||
} | |||
/** | |||
@@ -144,7 +144,8 @@ class ProcessDestroyer implements Runnable { | |||
// Cf.: http://developer.java.sun.com/developer/bugParade/bugs/4533087.html | |||
destroyProcessThread.setShouldDestroy(false); | |||
if (!destroyProcessThread.getThreadGroup().isDestroyed()) { | |||
// start() would throw IllegalThreadStateException from ThreadGroup.add if it were destroyed | |||
// start() would throw IllegalThreadStateException from | |||
// ThreadGroup.add if it were destroyed | |||
destroyProcessThread.start(); | |||
} | |||
// this should return quickly, since it basically is a NO-OP. | |||
@@ -606,8 +606,9 @@ public class Property extends Task { | |||
String propertyValue = props.getProperty(name); | |||
Vector fragments = new Vector(); | |||
Vector propertyRefs = new Vector(); | |||
PropertyHelper.getPropertyHelper(this.getProject()).parsePropertyString(propertyValue, fragments, | |||
propertyRefs); | |||
PropertyHelper.getPropertyHelper( | |||
this.getProject()).parsePropertyString( | |||
propertyValue, fragments, propertyRefs); | |||
if (propertyRefs.size() != 0) { | |||
referencesSeen.push(name); | |||