You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by mb...@apache.org on 2017/04/13 15:16:30 UTC
[30/34] ant git commit: java 5-8
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java b/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
index 60904e0..562ed8d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
@@ -107,16 +107,18 @@ public class ConditionTask extends ConditionBase {
*/
public void execute() throws BuildException {
if (countConditions() > 1) {
- throw new BuildException("You must not nest more than one condition into <"
- + getTaskName() + ">");
+ throw new BuildException(
+ "You must not nest more than one condition into <%s>",
+ getTaskName());
}
if (countConditions() < 1) {
- throw new BuildException("You must nest a condition into <" + getTaskName() + ">");
+ throw new BuildException("You must nest a condition into <%s>",
+ getTaskName());
}
if (property == null) {
throw new BuildException("The property attribute is required.");
}
- Condition c = (Condition) getConditions().nextElement();
+ Condition c = getConditions().nextElement();
if (c.eval()) {
log("Condition true; setting " + property + " to " + value, Project.MSG_DEBUG);
PropertyHelper.getPropertyHelper(getProject()).setNewProperty(property, value);
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/Copy.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java
index 2394b8f..3c08279 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Copy.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java
@@ -26,6 +26,7 @@ import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
@@ -75,7 +76,7 @@ public class Copy extends Task {
protected File file = null; // the source file
protected File destFile = null; // the destination file
protected File destDir = null; // the destination directory
- protected Vector<ResourceCollection> rcs = new Vector<ResourceCollection>();
+ protected Vector<ResourceCollection> rcs = new Vector<>();
// here to provide API backwards compatibility
protected Vector<ResourceCollection> filesets = rcs;
@@ -88,15 +89,15 @@ public class Copy extends Task {
protected boolean includeEmpty = true;
protected boolean failonerror = true;
- protected Hashtable<String, String[]> fileCopyMap = new LinkedHashtable<String, String[]>();
- protected Hashtable<String, String[]> dirCopyMap = new LinkedHashtable<String, String[]>();
- protected Hashtable<File, File> completeDirMap = new LinkedHashtable<File, File>();
+ protected Hashtable<String, String[]> fileCopyMap = new LinkedHashtable<>();
+ protected Hashtable<String, String[]> dirCopyMap = new LinkedHashtable<>();
+ protected Hashtable<File, File> completeDirMap = new LinkedHashtable<>();
protected Mapper mapperElement = null;
protected FileUtils fileUtils;
//CheckStyle:VisibilityModifier ON
- private final Vector<FilterChain> filterChains = new Vector<FilterChain>();
- private final Vector<FilterSet> filterSets = new Vector<FilterSet>();
+ private final Vector<FilterChain> filterChains = new Vector<>();
+ private final Vector<FilterSet> filterSets = new Vector<>();
private String inputEncoding = null;
private String outputEncoding = null;
private long granularity = 0;
@@ -474,18 +475,17 @@ public class Copy extends Task {
separate lists and then each list is handled in one go.
*/
- final HashMap<File, List<String>> filesByBasedir = new HashMap<File, List<String>>();
- final HashMap<File, List<String>> dirsByBasedir = new HashMap<File, List<String>>();
- final HashSet<File> baseDirs = new HashSet<File>();
- final ArrayList<Resource> nonFileResources = new ArrayList<Resource>();
- final int size = rcs.size();
- for (int i = 0; i < size; i++) {
- final ResourceCollection rc = rcs.elementAt(i);
+ final Map<File, List<String>> filesByBasedir = new HashMap<>();
+ final Map<File, List<String>> dirsByBasedir = new HashMap<>();
+ final Set<File> baseDirs = new HashSet<>();
+ final List<Resource> nonFileResources = new ArrayList<>();
+
+ for (ResourceCollection rc : rcs) {
// Step (1) - beware of the ZipFileSet
if (rc instanceof FileSet && rc.isFilesystemOnly()) {
final FileSet fs = (FileSet) rc;
- DirectoryScanner ds = null;
+ DirectoryScanner ds;
try {
ds = fs.getDirectoryScanner(getProject());
} catch (final BuildException e) {
@@ -493,12 +493,11 @@ public class Copy extends Task {
|| !getMessage(e).endsWith(DirectoryScanner
.DOES_NOT_EXIST_POSTFIX)) {
throw e;
- } else {
- if (!quiet) {
- log("Warning: " + getMessage(e), Project.MSG_ERR);
- }
- continue;
}
+ if (!quiet) {
+ log("Warning: " + getMessage(e), Project.MSG_ERR);
+ }
+ continue;
}
final File fromDir = fs.getDir(getProject());
@@ -574,7 +573,7 @@ public class Copy extends Task {
}
}
- if (nonFileResources.size() > 0 || singleResource != null) {
+ if (!nonFileResources.isEmpty() || singleResource != null) {
final Resource[] nonFiles =
nonFileResources.toArray(new Resource[nonFileResources.size()]);
// restrict to out-of-date resources
@@ -645,8 +644,9 @@ public class Copy extends Task {
}
}
- private void iterateOverBaseDirs(
- final HashSet<File> baseDirs, final HashMap<File, List<String>> dirsByBasedir, final HashMap<File, List<String>> filesByBasedir) {
+ private void iterateOverBaseDirs(final Set<File> baseDirs,
+ final Map<File, List<String>> dirsByBasedir,
+ final Map<File, List<String>> filesByBasedir) {
for (final File f : baseDirs) {
final List<String> files = filesByBasedir.get(f);
@@ -672,7 +672,7 @@ public class Copy extends Task {
* @exception BuildException if an error occurs.
*/
protected void validateAttributes() throws BuildException {
- if (file == null && rcs.size() == 0) {
+ if (file == null && rcs.isEmpty()) {
throw new BuildException(
"Specify at least one source--a file or a resource collection.");
}
@@ -686,36 +686,36 @@ public class Copy extends Task {
if (file != null && file.isDirectory()) {
throw new BuildException("Use a resource collection to copy directories.");
}
- if (destFile != null && rcs.size() > 0) {
+ if (destFile != null && !rcs.isEmpty()) {
if (rcs.size() > 1) {
throw new BuildException(
"Cannot concatenate multiple files into a single file.");
- } else {
- final ResourceCollection rc = rcs.elementAt(0);
- if (!rc.isFilesystemOnly() && !supportsNonFileResources()) {
- throw new BuildException("Only FileSystem resources are"
- + " supported.");
- }
- if (rc.size() == 0) {
- throw new BuildException(MSG_WHEN_COPYING_EMPTY_RC_TO_FILE);
- } else if (rc.size() == 1) {
- final Resource res = rc.iterator().next();
- final FileProvider r = res.as(FileProvider.class);
- if (file == null) {
- if (r != null) {
- file = r.getFile();
- } else {
- singleResource = res;
- }
- rcs.removeElementAt(0);
+ }
+ final ResourceCollection rc = rcs.elementAt(0);
+ if (!rc.isFilesystemOnly() && !supportsNonFileResources()) {
+ throw new BuildException(
+ "Only FileSystem resources are supported.");
+ }
+ if (rc.isEmpty()) {
+ throw new BuildException(MSG_WHEN_COPYING_EMPTY_RC_TO_FILE);
+ }
+ if (rc.size() == 1) {
+ final Resource res = rc.iterator().next();
+ final FileProvider r = res.as(FileProvider.class);
+ if (file == null) {
+ if (r != null) {
+ file = r.getFile();
} else {
- throw new BuildException(
- "Cannot concatenate multiple files into a single file.");
+ singleResource = res;
}
+ rcs.removeElementAt(0);
} else {
throw new BuildException(
"Cannot concatenate multiple files into a single file.");
}
+ } else {
+ throw new BuildException(
+ "Cannot concatenate multiple files into a single file.");
}
}
if (destFile != null) {
@@ -811,34 +811,28 @@ public class Copy extends Task {
*/
protected Map<Resource, String[]> buildMap(final Resource[] fromResources, final File toDir,
final FileNameMapper mapper) {
- final HashMap<Resource, String[]> map = new HashMap<Resource, String[]>();
- Resource[] toCopy = null;
+ final Map<Resource, String[]> map = new HashMap<>();
+ Resource[] toCopy;
if (forceOverwrite) {
- final Vector<Resource> v = new Vector<Resource>();
+ final List<Resource> v = new ArrayList<>();
for (int i = 0; i < fromResources.length; i++) {
if (mapper.mapFileName(fromResources[i].getName()) != null) {
- v.addElement(fromResources[i]);
+ v.add(fromResources[i]);
}
}
- toCopy = new Resource[v.size()];
- v.copyInto(toCopy);
+ toCopy = v.toArray(new Resource[v.size()]);
} else {
toCopy = ResourceUtils.selectOutOfDateSources(this, fromResources,
mapper,
- new ResourceFactory() {
- public Resource getResource(final String name) {
- return new FileResource(toDir, name);
- }
- },
+ (ResourceFactory) name -> new FileResource(toDir, name),
granularity);
}
for (int i = 0; i < toCopy.length; i++) {
final String[] mappedFiles = mapper.mapFileName(toCopy[i].getName());
- for (int j = 0; j < mappedFiles.length; j++) {
- if (mappedFiles[j] == null) {
- throw new BuildException("Can't copy a resource without a"
- + " name if the mapper doesn't"
- + " provide one.");
+ for (String mappedFile : mappedFiles) {
+ if (mappedFile == null) {
+ throw new BuildException(
+ "Can't copy a resource without a name if the mapper doesn't provide one.");
}
}
@@ -861,7 +855,7 @@ public class Copy extends Task {
* This is a good method for subclasses to override.
*/
protected void doFileOperations() {
- if (fileCopyMap.size() > 0) {
+ if (!fileCopyMap.isEmpty()) {
log("Copying " + fileCopyMap.size()
+ " file" + (fileCopyMap.size() == 1 ? "" : "s")
+ " to " + destDir.getAbsolutePath());
@@ -870,9 +864,7 @@ public class Copy extends Task {
final String fromFile = e.getKey();
final String[] toFiles = e.getValue();
- for (int i = 0; i < toFiles.length; i++) {
- final String toFile = toFiles[i];
-
+ for (final String toFile : toFiles) {
if (fromFile.equals(toFile)) {
log("Skipping self-copy of " + fromFile, verbosity);
continue;
@@ -916,8 +908,8 @@ public class Copy extends Task {
if (includeEmpty) {
int createCount = 0;
for (final String[] dirs : dirCopyMap.values()) {
- for (int i = 0; i < dirs.length; i++) {
- final File d = new File(dirs[i]);
+ for (String dir : dirs) {
+ final File d = new File(dir);
if (!d.exists()) {
if (!(d.mkdirs() || d.isDirectory())) {
log("Unable to create directory "
@@ -947,7 +939,7 @@ public class Copy extends Task {
* @since Ant 1.7
*/
protected void doResourceOperations(final Map<Resource, String[]> map) {
- if (map.size() > 0) {
+ if (!map.isEmpty()) {
log("Copying " + map.size()
+ " resource" + (map.size() == 1 ? "" : "s")
+ " to " + destDir.getAbsolutePath());
@@ -1026,7 +1018,7 @@ public class Copy extends Task {
baseDir = getKeyFile(baseDir);
List<String> l = m.get(baseDir);
if (l == null) {
- l = new ArrayList<String>(names.length);
+ l = new ArrayList<>(names.length);
m.put(baseDir, l);
}
l.addAll(java.util.Arrays.asList(names));
@@ -1085,7 +1077,7 @@ public class Copy extends Task {
*/
private String getDueTo(final Exception ex) {
final boolean baseIOException = ex.getClass() == IOException.class;
- final StringBuffer message = new StringBuffer();
+ final StringBuilder message = new StringBuilder();
if (!baseIOException || ex.getMessage() == null) {
message.append(ex.getClass().getName());
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/Copydir.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Copydir.java b/src/main/org/apache/tools/ant/taskdefs/Copydir.java
index 8b4efc3..7a099ab 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Copydir.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Copydir.java
@@ -35,6 +35,7 @@ import org.apache.tools.ant.Project;
* @deprecated The copydir task is deprecated since Ant 1.2. Use copy instead.
*/
+@Deprecated
public class Copydir extends MatchingTask {
private File srcDir;
@@ -42,7 +43,7 @@ public class Copydir extends MatchingTask {
private boolean filtering = false;
private boolean flatten = false;
private boolean forceOverwrite = false;
- private Hashtable<String, String> filecopyList = new Hashtable<String, String>();
+ private Map<String, String> filecopyList = new Hashtable<>();
/**
* The src attribute
@@ -94,6 +95,7 @@ public class Copydir extends MatchingTask {
* Execute the task.
* @throws BuildException on error
*/
+ @Override
public void execute() throws BuildException {
log("DEPRECATED - The copydir task is deprecated. Use copy instead.");
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/Copyfile.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Copyfile.java b/src/main/org/apache/tools/ant/taskdefs/Copyfile.java
index e9acb1d..55bd1f4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Copyfile.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Copyfile.java
@@ -34,6 +34,7 @@ import org.apache.tools.ant.Task;
* copy instead.
*/
+@Deprecated
public class Copyfile extends Task {
private File srcFile;
@@ -80,6 +81,7 @@ public class Copyfile extends Task {
* Execute the task.
* @throws BuildException on error
*/
+ @Override
public void execute() throws BuildException {
log("DEPRECATED - The copyfile task is deprecated. Use copy instead.");
@@ -107,9 +109,9 @@ public class Copyfile extends Task {
try {
getProject().copyFile(srcFile, destFile, filtering, forceOverwrite);
} catch (IOException ioe) {
- String msg = "Error copying file: " + srcFile.getAbsolutePath()
- + " due to " + ioe.getMessage();
- throw new BuildException(msg);
+ throw new BuildException(
+ "Error copying file: " + srcFile.getAbsolutePath()
+ + " due to " + ioe.getMessage());
}
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java b/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java
index 6b912e2..45cdfc3 100644
--- a/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java
+++ b/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java
@@ -45,29 +45,28 @@ public class DefaultExcludes extends Task {
*
* @exception BuildException if something goes wrong with the build
*/
+ @Override
public void execute() throws BuildException {
- if (!defaultrequested && add.equals("") && remove.equals("") && !echo) {
- throw new BuildException("<defaultexcludes> task must set "
- + "at least one attribute (echo=\"false\""
- + " doesn't count since that is the default");
+ if (!defaultrequested && "".equals(add) && "".equals(remove) && !echo) {
+ throw new BuildException(
+ "<defaultexcludes> task must set at least one attribute (echo=\"false\" doesn't count since that is the default");
}
if (defaultrequested) {
DirectoryScanner.resetDefaultExcludes();
}
- if (!add.equals("")) {
+ if (!"".equals(add)) {
DirectoryScanner.addDefaultExclude(add);
}
- if (!remove.equals("")) {
+ if (!"".equals(remove)) {
DirectoryScanner.removeDefaultExclude(remove);
}
if (echo) {
- StringBuffer message
- = new StringBuffer("Current Default Excludes:");
+ StringBuilder message
+ = new StringBuilder("Current Default Excludes:");
message.append(StringUtils.LINE_SEP);
- String[] excludes = DirectoryScanner.getDefaultExcludes();
- for (int i = 0; i < excludes.length; i++) {
+ for (String exclude : DirectoryScanner.getDefaultExcludes()) {
message.append(" ");
- message.append(excludes[i]);
+ message.append(exclude);
message.append(StringUtils.LINE_SEP);
}
log(message.toString(), logLevel);
@@ -111,5 +110,4 @@ public class DefaultExcludes extends Task {
this.echo = echo;
}
-
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/Definer.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Definer.java b/src/main/org/apache/tools/ant/taskdefs/Definer.java
index e4e3ea3..de4c118 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Definer.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Definer.java
@@ -50,13 +50,14 @@ public abstract class Definer extends DefBase {
/**
* the extension of an antlib file for autoloading.
- * {@value[
+ * {@value /antlib.xml}
*/
private static final String ANTLIB_XML = "/antlib.xml";
private static final ThreadLocal<Map<URL, Location>> RESOURCE_STACK = new ThreadLocal<Map<URL, Location>>() {
+ @Override
protected Map<URL, Location> initialValue() {
- return new HashMap<URL, Location>();
+ return new HashMap<>();
}
};
@@ -120,8 +121,10 @@ public abstract class Definer extends DefBase {
* get the values
* @return an array of the allowed values for this attribute.
*/
+ @Override
public String[] getValues() {
- return new String[] {POLICY_FAIL, POLICY_REPORT, POLICY_IGNORE, POLICY_FAILALL};
+ return new String[] { POLICY_FAIL, POLICY_REPORT, POLICY_IGNORE,
+ POLICY_FAILALL };
}
}
@@ -138,8 +141,9 @@ public abstract class Definer extends DefBase {
* get the values
* @return an array of the allowed values for this attribute.
*/
+ @Override
public String[] getValues() {
- return new String[] {"properties", "xml"};
+ return new String[] { "properties", "xml" };
}
}
@@ -202,6 +206,7 @@ public abstract class Definer extends DefBase {
*
* @exception BuildException if an error occurs
*/
+ @Override
public void execute() throws BuildException {
ClassLoader al = createLoader();
@@ -223,23 +228,22 @@ public abstract class Definer extends DefBase {
setResource(makeResourceFromURI(uri1));
} else {
throw new BuildException(
- "Only antlib URIs can be located from the URI alone,"
- + " not the URI '" + getURI() + "'");
+ "Only antlib URIs can be located from the URI alone, not the URI '"
+ + getURI() + "'");
}
}
if (name != null) {
if (classname == null) {
- throw new BuildException(
- "classname attribute of " + getTaskName() + " element "
- + "is undefined", getLocation());
+ throw new BuildException("classname attribute of "
+ + getTaskName() + " element is undefined", getLocation());
}
addDefinition(al, name, classname);
} else {
if (classname != null) {
- String msg = "You must not specify classname "
- + "together with file or resource.";
- throw new BuildException(msg, getLocation());
+ throw new BuildException(
+ "You must not specify classname together with file or resource.",
+ getLocation());
}
final Enumeration<URL> urls;
if (file == null) {
@@ -263,21 +267,19 @@ public abstract class Definer extends DefBase {
if (fmt == Format.PROPERTIES) {
loadProperties(al, url);
break;
+ } else if (RESOURCE_STACK.get().get(url) != null) {
+ log("Warning: Recursive loading of " + url
+ + " ignored"
+ + " at " + getLocation()
+ + " originally loaded at "
+ + RESOURCE_STACK.get().get(url),
+ Project.MSG_WARN);
} else {
- if (RESOURCE_STACK.get().get(url) != null) {
- log("Warning: Recursive loading of " + url
- + " ignored"
- + " at " + getLocation()
- + " originally loaded at "
- + RESOURCE_STACK.get().get(url),
- Project.MSG_WARN);
- } else {
- try {
- RESOURCE_STACK.get().put(url, getLocation());
- loadAntlib(al, url);
- } finally {
- RESOURCE_STACK.get().remove(url);
- }
+ try {
+ RESOURCE_STACK.get().put(url, getLocation());
+ loadAntlib(al, url);
+ } finally {
+ RESOURCE_STACK.get().remove(url);
}
}
}
@@ -290,7 +292,6 @@ public abstract class Definer extends DefBase {
* @param uri the xml namespace uri that to convert.
* @return the name of a resource. It may not exist
*/
-
public static String makeResourceFromURI(String uri) {
String path = uri.substring(MagicNames.ANTLIB_PREFIX.length());
String resource;
@@ -391,9 +392,7 @@ public abstract class Definer extends DefBase {
* @param url the url to get the definitions from
*/
protected void loadProperties(ClassLoader al, URL url) {
- InputStream is = null;
- try {
- is = url.openStream();
+ try (InputStream is = url.openStream()) {
if (is == null) {
log("Could not load definitions from " + url,
Project.MSG_WARN);
@@ -401,16 +400,13 @@ public abstract class Definer extends DefBase {
}
Properties props = new Properties();
props.load(is);
- Enumeration<?> keys = props.keys();
- while (keys.hasMoreElements()) {
- name = ((String) keys.nextElement());
+ for (String key : props.stringPropertyNames()) {
+ name = key;
classname = props.getProperty(name);
addDefinition(al, name, classname);
}
} catch (IOException ex) {
throw new BuildException(ex, getLocation());
- } finally {
- FileUtils.close(is);
}
}
@@ -559,7 +555,6 @@ public abstract class Definer extends DefBase {
this.adaptToClass = adaptToClass;
}
-
/**
* Add a definition using the attributes of Definer
*
@@ -601,15 +596,16 @@ public abstract class Definer extends DefBase {
ComponentHelper.getComponentHelper(getProject())
.addDataTypeDefinition(def);
} catch (ClassNotFoundException cnfe) {
- String msg = getTaskName() + " class " + classname
- + " cannot be found"
- + "\n using the classloader " + al;
- throw new BuildException(msg, cnfe, getLocation());
+ throw new BuildException(
+ getTaskName() + " class " + classname
+ + " cannot be found\n using the classloader " + al,
+ cnfe, getLocation());
} catch (NoClassDefFoundError ncdfe) {
- String msg = getTaskName() + " A class needed by class "
- + classname + " cannot be found: " + ncdfe.getMessage()
- + "\n using the classloader " + al;
- throw new BuildException(msg, ncdfe, getLocation());
+ throw new BuildException(
+ getTaskName() + " A class needed by class " + classname
+ + " cannot be found: " + ncdfe.getMessage()
+ + "\n using the classloader " + al,
+ ncdfe, getLocation());
}
} catch (BuildException ex) {
switch (onError) {
@@ -633,7 +629,7 @@ public abstract class Definer extends DefBase {
*/
private void tooManyDefinitions() {
throw new BuildException(
- "Only one of the attributes name, file and resource"
- + " can be set", getLocation());
+ "Only one of the attributes name, file and resource can be set",
+ getLocation());
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/Delete.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Delete.java b/src/main/org/apache/tools/ant/taskdefs/Delete.java
index 6c34ccf..ffdf9a8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Delete.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Delete.java
@@ -19,6 +19,7 @@
package org.apache.tools.ant.taskdefs;
import java.io.File;
+import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
@@ -79,33 +80,43 @@ import org.apache.tools.ant.util.SymbolicLinkUtils;
public class Delete extends MatchingTask {
private static final ResourceComparator REVERSE_FILESYSTEM = new Reverse(new FileSystem());
private static final ResourceSelector EXISTS = new Exists();
+ private static FileUtils FILE_UTILS = FileUtils.getFileUtils();
+ private static SymbolicLinkUtils SYMLINK_UTILS =
+ SymbolicLinkUtils.getSymbolicLinkUtils();
private static class ReverseDirs implements ResourceCollection {
- static final Comparator<Comparable<?>> REVERSE = new Comparator<Comparable<?>>() {
- public int compare(Comparable<?> foo, Comparable<?> bar) {
- return ((Comparable) foo).compareTo(bar) * -1;
- }
- };
+
private Project project;
private File basedir;
private String[] dirs;
+
ReverseDirs(Project project, File basedir, String[] dirs) {
this.project = project;
this.basedir = basedir;
this.dirs = dirs;
- Arrays.sort(this.dirs, REVERSE);
+ Arrays.sort(this.dirs, Comparator.reverseOrder());
}
+
+ @Override
public Iterator<Resource> iterator() {
return new FileResourceIterator(project, basedir, dirs);
}
- public boolean isFilesystemOnly() { return true; }
- public int size() { return dirs.length; }
+
+ @Override
+ public boolean isFilesystemOnly() {
+ return true;
+ }
+
+ @Override
+ public int size() {
+ return dirs.length;
+ }
}
// CheckStyle:VisibilityModifier OFF - bc
protected File file = null;
protected File dir = null;
- protected Vector<FileSet> filesets = new Vector<FileSet>();
+ protected Vector<FileSet> filesets = new Vector<>();
protected boolean usedMatchingTask = false;
// by default, remove matching empty dirs
protected boolean includeEmpty = false;
@@ -117,9 +128,6 @@ public class Delete extends MatchingTask {
private boolean deleteOnExit = false;
private boolean removeNotFollowedSymlinks = false;
private Resources rcs = null;
- private static FileUtils FILE_UTILS = FileUtils.getFileUtils();
- private static SymbolicLinkUtils SYMLINK_UTILS =
- SymbolicLinkUtils.getSymbolicLinkUtils();
private boolean performGc = Os.isFamily("windows");
/**
@@ -175,9 +183,9 @@ public class Delete extends MatchingTask {
*
* @param failonerror true or false
*/
- public void setFailOnError(boolean failonerror) {
- this.failonerror = failonerror;
- }
+ public void setFailOnError(boolean failonerror) {
+ this.failonerror = failonerror;
+ }
/**
* If true, on failure to delete, note the error and set
@@ -185,10 +193,9 @@ public class Delete extends MatchingTask {
*
* @param deleteOnExit true or false
*/
- public void setDeleteOnExit(boolean deleteOnExit) {
- this.deleteOnExit = deleteOnExit;
- }
-
+ public void setDeleteOnExit(boolean deleteOnExit) {
+ this.deleteOnExit = deleteOnExit;
+ }
/**
* If true, delete empty directories.
@@ -212,10 +219,10 @@ public class Delete extends MatchingTask {
performGc = b;
}
- /**
- * Adds a set of files to be deleted.
- * @param set the set of files to be deleted
- */
+ /**
+ * Adds a set of files to be deleted.
+ * @param set the set of files to be deleted
+ */
public void addFileset(FileSet set) {
filesets.addElement(set);
}
@@ -239,6 +246,7 @@ public class Delete extends MatchingTask {
* add a name entry on the include list
* @return a NameEntry object to be configured
*/
+ @Override
public PatternSet.NameEntry createInclude() {
usedMatchingTask = true;
return super.createInclude();
@@ -248,6 +256,7 @@ public class Delete extends MatchingTask {
* add a name entry on the include files list
* @return an NameEntry object to be configured
*/
+ @Override
public PatternSet.NameEntry createIncludesFile() {
usedMatchingTask = true;
return super.createIncludesFile();
@@ -257,6 +266,7 @@ public class Delete extends MatchingTask {
* add a name entry on the exclude list
* @return an NameEntry object to be configured
*/
+ @Override
public PatternSet.NameEntry createExclude() {
usedMatchingTask = true;
return super.createExclude();
@@ -266,6 +276,7 @@ public class Delete extends MatchingTask {
* add a name entry on the include files list
* @return an NameEntry object to be configured
*/
+ @Override
public PatternSet.NameEntry createExcludesFile() {
usedMatchingTask = true;
return super.createExcludesFile();
@@ -275,6 +286,7 @@ public class Delete extends MatchingTask {
* add a set of patterns
* @return PatternSet object to be configured
*/
+ @Override
public PatternSet createPatternSet() {
usedMatchingTask = true;
return super.createPatternSet();
@@ -286,6 +298,7 @@ public class Delete extends MatchingTask {
*
* @param includes the string containing the include patterns
*/
+ @Override
public void setIncludes(String includes) {
usedMatchingTask = true;
super.setIncludes(includes);
@@ -297,6 +310,7 @@ public class Delete extends MatchingTask {
*
* @param excludes the string containing the exclude patterns
*/
+ @Override
public void setExcludes(String excludes) {
usedMatchingTask = true;
super.setExcludes(excludes);
@@ -309,6 +323,7 @@ public class Delete extends MatchingTask {
* should be used, "false"|"off"|"no" when they
* shouldn't be used.
*/
+ @Override
public void setDefaultexcludes(boolean useDefaultExcludes) {
usedMatchingTask = true;
super.setDefaultexcludes(useDefaultExcludes);
@@ -320,6 +335,7 @@ public class Delete extends MatchingTask {
* @param includesfile A string containing the filename to fetch
* the include patterns from.
*/
+ @Override
public void setIncludesfile(File includesfile) {
usedMatchingTask = true;
super.setIncludesfile(includesfile);
@@ -331,6 +347,7 @@ public class Delete extends MatchingTask {
* @param excludesfile A string containing the filename to fetch
* the include patterns from.
*/
+ @Override
public void setExcludesfile(File excludesfile) {
usedMatchingTask = true;
super.setExcludesfile(excludesfile);
@@ -342,6 +359,7 @@ public class Delete extends MatchingTask {
* @param isCaseSensitive "true"|"on"|"yes" if file system is case
* sensitive, "false"|"off"|"no" when not.
*/
+ @Override
public void setCaseSensitive(boolean isCaseSensitive) {
usedMatchingTask = true;
super.setCaseSensitive(isCaseSensitive);
@@ -352,6 +370,7 @@ public class Delete extends MatchingTask {
*
* @param followSymlinks whether or not symbolic links should be followed
*/
+ @Override
public void setFollowSymlinks(boolean followSymlinks) {
usedMatchingTask = true;
super.setFollowSymlinks(followSymlinks);
@@ -371,6 +390,7 @@ public class Delete extends MatchingTask {
* add a "Select" selector entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addSelector(SelectSelector selector) {
usedMatchingTask = true;
super.addSelector(selector);
@@ -380,6 +400,7 @@ public class Delete extends MatchingTask {
* add an "And" selector entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addAnd(AndSelector selector) {
usedMatchingTask = true;
super.addAnd(selector);
@@ -389,6 +410,7 @@ public class Delete extends MatchingTask {
* add an "Or" selector entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addOr(OrSelector selector) {
usedMatchingTask = true;
super.addOr(selector);
@@ -398,6 +420,7 @@ public class Delete extends MatchingTask {
* add a "Not" selector entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addNot(NotSelector selector) {
usedMatchingTask = true;
super.addNot(selector);
@@ -407,6 +430,7 @@ public class Delete extends MatchingTask {
* add a "None" selector entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addNone(NoneSelector selector) {
usedMatchingTask = true;
super.addNone(selector);
@@ -416,6 +440,7 @@ public class Delete extends MatchingTask {
* add a majority selector entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addMajority(MajoritySelector selector) {
usedMatchingTask = true;
super.addMajority(selector);
@@ -425,6 +450,7 @@ public class Delete extends MatchingTask {
* add a selector date entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addDate(DateSelector selector) {
usedMatchingTask = true;
super.addDate(selector);
@@ -434,6 +460,7 @@ public class Delete extends MatchingTask {
* add a selector size entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addSize(SizeSelector selector) {
usedMatchingTask = true;
super.addSize(selector);
@@ -443,6 +470,7 @@ public class Delete extends MatchingTask {
* add a selector filename entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addFilename(FilenameSelector selector) {
usedMatchingTask = true;
super.addFilename(selector);
@@ -452,6 +480,7 @@ public class Delete extends MatchingTask {
* add an extended selector entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addCustom(ExtendSelector selector) {
usedMatchingTask = true;
super.addCustom(selector);
@@ -461,6 +490,7 @@ public class Delete extends MatchingTask {
* add a contains selector entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addContains(ContainsSelector selector) {
usedMatchingTask = true;
super.addContains(selector);
@@ -470,6 +500,7 @@ public class Delete extends MatchingTask {
* add a present selector entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addPresent(PresentSelector selector) {
usedMatchingTask = true;
super.addPresent(selector);
@@ -479,6 +510,7 @@ public class Delete extends MatchingTask {
* add a depth selector entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addDepth(DepthSelector selector) {
usedMatchingTask = true;
super.addDepth(selector);
@@ -488,6 +520,7 @@ public class Delete extends MatchingTask {
* add a depends selector entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addDepend(DependSelector selector) {
usedMatchingTask = true;
super.addDepend(selector);
@@ -497,6 +530,7 @@ public class Delete extends MatchingTask {
* add a regular expression selector entry on the selector list
* @param selector the selector to be added
*/
+ @Override
public void addContainsRegexp(ContainsRegexpSelector selector) {
usedMatchingTask = true;
super.addContainsRegexp(selector);
@@ -507,6 +541,7 @@ public class Delete extends MatchingTask {
* @param selector the selector to add
* @since ant 1.6
*/
+ @Override
public void addModified(ModifiedSelector selector) {
usedMatchingTask = true;
super.addModified(selector);
@@ -517,6 +552,7 @@ public class Delete extends MatchingTask {
* @param selector the selector to be added
* @since Ant 1.6
*/
+ @Override
public void add(FileSelector selector) {
usedMatchingTask = true;
super.add(selector);
@@ -526,21 +562,22 @@ public class Delete extends MatchingTask {
* Delete the file(s).
* @exception BuildException if an error occurs
*/
+ @Override
public void execute() throws BuildException {
if (usedMatchingTask) {
- log("DEPRECATED - Use of the implicit FileSet is deprecated. "
- + "Use a nested fileset element instead.", quiet ? Project.MSG_VERBOSE : verbosity);
+ log("DEPRECATED - Use of the implicit FileSet is deprecated. Use a nested fileset element instead.",
+ quiet ? Project.MSG_VERBOSE : verbosity);
}
- if (file == null && dir == null && filesets.size() == 0 && rcs == null) {
- throw new BuildException("At least one of the file or dir "
- + "attributes, or a nested resource collection, "
- + "must be set.");
+ if (file == null && dir == null && filesets.isEmpty() && rcs == null) {
+ throw new BuildException(
+ "At least one of the file or dir attributes, or a nested resource collection, must be set.");
}
if (quiet && failonerror) {
- throw new BuildException("quiet and failonerror cannot both be "
- + "set to true", getLocation());
+ throw new BuildException(
+ "quiet and failonerror cannot both be set to true",
+ getLocation());
}
// delete the single file
@@ -548,8 +585,8 @@ public class Delete extends MatchingTask {
if (file.exists()) {
if (file.isDirectory()) {
log("Directory " + file.getAbsolutePath()
- + " cannot be removed using the file attribute. "
- + "Use dir instead.", quiet ? Project.MSG_VERBOSE : verbosity);
+ + " cannot be removed using the file attribute. Use dir instead.",
+ quiet ? Project.MSG_VERBOSE : verbosity);
} else {
log("Deleting: " + file.getAbsolutePath());
@@ -610,11 +647,11 @@ public class Delete extends MatchingTask {
final int size = filesets.size();
for (int i = 0; i < size; i++) {
- FileSet fs = (FileSet) filesets.get(i);
+ FileSet fs = filesets.get(i);
if (fs.getProject() == null) {
- log("Deleting fileset with no project specified;"
- + " assuming executing project", Project.MSG_VERBOSE);
- fs = (FileSet) fs.clone();
+ log("Deleting fileset with no project specified; assuming executing project",
+ Project.MSG_VERBOSE);
+ fs = fs.clone();
fs.setProject(getProject());
}
final File fsDir = fs.getDir();
@@ -634,12 +671,15 @@ public class Delete extends MatchingTask {
// iterating, capture the results now and store them
final String[] files = ds.getIncludedFiles();
resourcesToDelete.add(new ResourceCollection() {
+ @Override
public boolean isFilesystemOnly() {
return true;
}
+ @Override
public int size() {
return files.length;
}
+ @Override
public Iterator<Resource> iterator() {
return new FileResourceIterator(getProject(),
fsDir, files);
@@ -656,7 +696,7 @@ public class Delete extends MatchingTask {
if (n.length > 0) {
String[] links = new String[n.length];
System.arraycopy(n, 0, links, 0, n.length);
- Arrays.sort(links, ReverseDirs.REVERSE);
+ Arrays.sort(links, Comparator.reverseOrder());
for (int l = 0; l < links.length; l++) {
try {
SYMLINK_UTILS
@@ -826,7 +866,7 @@ public class Delete extends MatchingTask {
private boolean isDanglingSymlink(File f) {
try {
return SYMLINK_UTILS.isDanglingSymbolicLink(f);
- } catch (java.io.IOException e) {
+ } catch (IOException e) {
log("Error while trying to detect " + f.getAbsolutePath()
+ " as broken symbolic link. " + e.getMessage(),
quiet ? Project.MSG_VERBOSE : verbosity);
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/DependSet.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/DependSet.java b/src/main/org/apache/tools/ant/taskdefs/DependSet.java
index dc42beb..ecc8ac3 100644
--- a/src/main/org/apache/tools/ant/taskdefs/DependSet.java
+++ b/src/main/org/apache/tools/ant/taskdefs/DependSet.java
@@ -102,12 +102,15 @@ public class DependSet extends MatchingTask {
private HideMissingBasedir(FileSet fs) {
this.fs = fs;
}
+ @Override
public Iterator<Resource> iterator() {
return basedirExists() ? fs.iterator() : Resources.EMPTY_ITERATOR;
}
+ @Override
public int size() {
return basedirExists() ? fs.size() : 0;
}
+ @Override
public boolean isFilesystemOnly() {
return true;
}
@@ -190,6 +193,7 @@ public class DependSet extends MatchingTask {
* Execute the task.
* @throws BuildException if errors occur.
*/
+ @Override
public void execute() throws BuildException {
if (sources == null) {
throw new BuildException(
@@ -200,12 +204,11 @@ public class DependSet extends MatchingTask {
"At least one set of target files must be specified");
}
//no sources = nothing to compare; no targets = nothing to delete:
- if (sources.size() > 0 && targets.size() > 0 && !uptodate(sources, targets)) {
+ if (!(sources.isEmpty() || targets.isEmpty() || uptodate(sources, targets))) {
log("Deleting all target files.", Project.MSG_VERBOSE);
if (verbose) {
- String[] t = targets.list();
- for (int i = 0; i < t.length; i++) {
- log("Deleting " + t[i]);
+ for (String t : targets.list()) {
+ log("Deleting " + t);
}
}
Delete delete = new Delete();
@@ -244,7 +247,7 @@ public class DependSet extends MatchingTask {
logMissing(missingSources, "source");
return false;
}
- Resource newestSource = (Resource) getNewest(sources);
+ Resource newestSource = getNewest(sources);
logWithModificationTime(newestSource, "newest source");
return oldestTarget.getLastModified() >= newestSource.getLastModified();
}
@@ -262,7 +265,6 @@ public class DependSet extends MatchingTask {
Iterator<Resource> i = rc.iterator();
if (!i.hasNext()) {
return null;
-
}
Resource xest = i.next();
while (i.hasNext()) {
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/Dirname.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Dirname.java b/src/main/org/apache/tools/ant/taskdefs/Dirname.java
index 9e085e7..2e952df 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Dirname.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Dirname.java
@@ -68,15 +68,14 @@ public class Dirname extends Task {
* Execute this task.
* @throws BuildException on error
*/
+ @Override
public void execute() throws BuildException {
if (property == null) {
throw new BuildException("property attribute required", getLocation());
}
if (file == null) {
throw new BuildException("file attribute required", getLocation());
- } else {
- String value = file.getParent();
- getProject().setNewProperty(property, value);
}
+ getProject().setNewProperty(property, file.getParent());
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/Ear.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Ear.java b/src/main/org/apache/tools/ant/taskdefs/Ear.java
index 6e08ecd..45ad50e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Ear.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Ear.java
@@ -55,6 +55,7 @@ public class Ear extends Jar {
* @deprecated since 1.5.x.
* Use setDestFile(destfile) instead.
*/
+ @Deprecated
public void setEarfile(File earFile) {
setDestFile(earFile);
}
@@ -66,9 +67,9 @@ public class Ear extends Jar {
public void setAppxml(File descr) {
deploymentDescriptor = descr;
if (!deploymentDescriptor.exists()) {
- throw new BuildException("Deployment descriptor: "
- + deploymentDescriptor
- + " does not exist.");
+ throw new BuildException(
+ "Deployment descriptor: %s does not exist.",
+ deploymentDescriptor);
}
// Create a ZipFileSet for this file, and pass it up.
@@ -78,7 +79,6 @@ public class Ear extends Jar {
super.addFileset(fs);
}
-
/**
* Adds zipfileset.
*
@@ -91,13 +91,13 @@ public class Ear extends Jar {
super.addFileset(fs);
}
-
/**
* Initialize the output stream.
* @param zOut the zip output stream.
* @throws IOException on I/O errors
* @throws BuildException on other errors
*/
+ @Override
protected void initZipOutputStream(ZipOutputStream zOut)
throws IOException, BuildException {
// If no webxml file is specified, it's an error.
@@ -116,6 +116,7 @@ public class Ear extends Jar {
* @param mode the Unix permissions to set.
* @throws IOException on error
*/
+ @Override
protected void zipFile(File file, ZipOutputStream zOut, String vPath,
int mode)
throws IOException {
@@ -147,6 +148,7 @@ public class Ear extends Jar {
* Make sure we don't think we already have a application.xml next
* time this task gets executed.
*/
+ @Override
protected void cleanUp() {
descriptorAdded = false;
super.cleanUp();
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/EchoXML.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/EchoXML.java b/src/main/org/apache/tools/ant/taskdefs/EchoXML.java
index 5873ab7..fa0e457 100644
--- a/src/main/org/apache/tools/ant/taskdefs/EchoXML.java
+++ b/src/main/org/apache/tools/ant/taskdefs/EchoXML.java
@@ -113,24 +113,26 @@ public class EchoXML extends XMLFragment {
public NamespacePolicy(String s) {
setValue(s);
}
+
/** {@inheritDoc}. */
@Override
public String[] getValues() {
- return new String[] {IGNORE, ELEMENTS, ALL};
+ return new String[] { IGNORE, ELEMENTS, ALL };
}
public DOMElementWriter.XmlNamespacePolicy getPolicy() {
String s = getValue();
if (IGNORE.equalsIgnoreCase(s)) {
return DOMElementWriter.XmlNamespacePolicy.IGNORE;
- } else if (ELEMENTS.equalsIgnoreCase(s)) {
+ }
+ if (ELEMENTS.equalsIgnoreCase(s)) {
return
DOMElementWriter.XmlNamespacePolicy.ONLY_QUALIFY_ELEMENTS;
- } else if (ALL.equalsIgnoreCase(s)) {
+ }
+ if (ALL.equalsIgnoreCase(s)) {
return DOMElementWriter.XmlNamespacePolicy.QUALIFY_ALL;
- } else {
- throw new BuildException("Invalid namespace policy: " + s);
}
+ throw new BuildException("Invalid namespace policy: " + s);
}
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/Exec.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Exec.java b/src/main/org/apache/tools/ant/taskdefs/Exec.java
index cfc6b76..a1c100f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Exec.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Exec.java
@@ -44,6 +44,7 @@ import org.apache.tools.ant.Task;
* delegate to {@link org.apache.tools.ant.taskdefs.Execute Execute}
* instead.
*/
+@Deprecated
public class Exec extends Task {
private String os;
private String out;
@@ -70,6 +71,7 @@ public class Exec extends Task {
* Execute the task.
* @throws BuildException on error
*/
+ @Override
public void execute() throws BuildException {
run(command);
}
@@ -160,9 +162,8 @@ public class Exec extends Task {
if (err != 0) {
if (failOnError) {
throw new BuildException("Exec returned: " + err, getLocation());
- } else {
- log("Result: " + err, Project.MSG_ERR);
}
+ log("Result: " + err, Project.MSG_ERR);
}
} catch (IOException ioe) {
throw new BuildException("Error exec: " + command, ioe, getLocation());
@@ -262,6 +263,7 @@ public class Exec extends Task {
}
}
+ @Override
public void run() {
try {
try {
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/ExecTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java
index dd93978..6ed6d90 100644
--- a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java
@@ -125,7 +125,7 @@ public class ExecTask extends Task {
*/
public void setTimeout(Integer value) {
setTimeout(
- (Long) ((value == null) ? null : new Long(value.intValue())));
+ (value == null) ? null : Long.valueOf(value.intValue()));
}
/**
@@ -167,8 +167,7 @@ public class ExecTask extends Task {
* @ant.attribute ignore="true"
*/
public void setCommand(Commandline cmdl) {
- log("The command attribute is deprecated.\n"
- + "Please use the executable attribute and nested arg elements.",
+ log("The command attribute is deprecated.\nPlease use the executable attribute and nested arg elements.",
Project.MSG_WARN);
this.cmdl = cmdl;
}
@@ -191,8 +190,8 @@ public class ExecTask extends Task {
*/
public void setInput(File input) {
if (inputString != null) {
- throw new BuildException("The \"input\" and \"inputstring\" "
- + "attributes cannot both be specified");
+ throw new BuildException(
+ "The \"input\" and \"inputstring\" attributes cannot both be specified");
}
this.input = input;
incompatibleWithSpawn = true;
@@ -205,8 +204,8 @@ public class ExecTask extends Task {
*/
public void setInputString(String inputString) {
if (input != null) {
- throw new BuildException("The \"input\" and \"inputstring\" "
- + "attributes cannot both be specified");
+ throw new BuildException(
+ "The \"input\" and \"inputstring\" attributes cannot both be specified");
}
this.inputString = inputString;
incompatibleWithSpawn = true;
@@ -484,6 +483,7 @@ public class ExecTask extends Task {
* <li>this list is not exhaustive or limitative</li>
* </ul>
*/
+ @Override
public void execute() throws BuildException {
// Quick fail if this is not a valid OS for the command
if (!isValidOs()) {
@@ -633,9 +633,8 @@ public class ExecTask extends Task {
String msg = "Timeout: killed the sub-process";
if (failOnError) {
throw new BuildException(msg);
- } else {
- log(msg, Project.MSG_WARN);
}
+ log(msg, Project.MSG_WARN);
}
maybeSetResultPropertyValue(returnCode);
redirector.complete();
@@ -643,9 +642,8 @@ public class ExecTask extends Task {
if (failOnError) {
throw new BuildException(getTaskType() + " returned: "
+ returnCode, getLocation());
- } else {
- log("Result: " + returnCode, Project.MSG_ERR);
}
+ log("Result: " + returnCode, Project.MSG_ERR);
}
} else {
exe.spawn();
@@ -672,9 +670,8 @@ public class ExecTask extends Task {
if (failIfExecFails) {
throw new BuildException("Execute failed: " + e.toString(), e,
getLocation());
- } else {
- log("Execute failed: " + e.toString(), Project.MSG_ERR);
}
+ log("Execute failed: " + e.toString(), Project.MSG_ERR);
} finally {
// close the output file if required
logFlush();
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/Execute.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Execute.java b/src/main/org/apache/tools/ant/taskdefs/Execute.java
index 956309a..7bf9d04 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Execute.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Execute.java
@@ -24,7 +24,7 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringReader;
-import java.util.ArrayList;
+import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -54,18 +54,6 @@ public class Execute {
*/
public static final int INVALID = Integer.MAX_VALUE;
- private String[] cmdl = null;
- private String[] env = null;
- private int exitValue = INVALID;
- private ExecuteStreamHandler streamHandler;
- private final ExecuteWatchdog watchdog;
- private File workingDirectory = null;
- private Project project = null;
- private boolean newEnvironment = false;
-
- /** Controls whether the VM is used to launch commands, where possible. */
- private boolean useVMLauncher = true;
-
private static String antWorkingDirectory = System.getProperty("user.dir");
private static Map<String, String> procEnvironment = null;
@@ -81,6 +69,18 @@ public class Execute {
}
}
+ private String[] cmdl = null;
+ private String[] env = null;
+ private int exitValue = INVALID;
+ private ExecuteStreamHandler streamHandler;
+ private final ExecuteWatchdog watchdog;
+ private File workingDirectory = null;
+ private Project project = null;
+ private boolean newEnvironment = false;
+
+ /** Controls whether the VM is used to launch commands, where possible. */
+ private boolean useVMLauncher = true;
+
/**
* Set whether or not you want the process to be spawned.
* Default is not spawned.
@@ -104,7 +104,7 @@ public class Execute {
* @return a map containing the environment variables.
* @since Ant 1.8.2
*/
- public static synchronized Map<String,String> getEnvironmentVariables() {
+ public static synchronized Map<String, String> getEnvironmentVariables() {
if (procEnvironment != null) {
return procEnvironment;
}
@@ -117,7 +117,7 @@ public class Execute {
}
}
- procEnvironment = new LinkedHashMap<String, String>();
+ procEnvironment = new LinkedHashMap<>();
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Execute exe = new Execute(new PumpStreamHandler(out));
@@ -149,7 +149,7 @@ public class Execute {
} else {
// New env var...append the previous one if we have it.
if (var != null) {
- int eq = var.indexOf("=");
+ int eq = var.indexOf('=');
procEnvironment.put(var.substring(0, eq),
var.substring(eq + 1));
}
@@ -158,10 +158,10 @@ public class Execute {
}
// Since we "look ahead" before adding, there's one last env var.
if (var != null) {
- int eq = var.indexOf("=");
+ int eq = var.indexOf('=');
procEnvironment.put(var.substring(0, eq), var.substring(eq + 1));
}
- } catch (java.io.IOException exc) {
+ } catch (IOException exc) {
exc.printStackTrace(); //NOSONAR
// Just try to see how much we got
}
@@ -177,7 +177,7 @@ public class Execute {
*/
@Deprecated
public static synchronized Vector<String> getProcEnvironment() {
- Vector<String> v = new Vector<String>();
+ Vector<String> v = new Vector<>();
for (Entry<String, String> entry : getEnvironmentVariables().entrySet()) {
v.add(entry.getKey() + "=" + entry.getValue());
}
@@ -194,17 +194,18 @@ public class Execute {
private static String[] getProcEnvCommand() {
if (Os.isFamily("os/2")) {
// OS/2 - use same mechanism as Windows 2000
- return new String[] {"cmd", "/c", "set"};
- } else if (Os.isFamily("windows")) {
+ return new String[] { "cmd", "/c", "set" };
+ }
+ if (Os.isFamily("windows")) {
// Determine if we're running under XP/2000/NT or 98/95
if (Os.isFamily("win9x")) {
// Windows 98/95
- return new String[] {"command.com", "/c", "set"};
- } else {
- // Windows XP/2000/NT/2003
- return new String[] {"cmd", "/c", "set"};
+ return new String[] { "command.com", "/c", "set" };
}
- } else if (Os.isFamily("z/os") || Os.isFamily("unix")) {
+ // Windows XP/2000/NT/2003
+ return new String[] { "cmd", "/c", "set" };
+ }
+ if (Os.isFamily("z/os") || Os.isFamily("unix")) {
// On most systems one could use: /bin/sh -c env
// Some systems have /bin/env, others /usr/bin/env, just try
@@ -218,16 +219,17 @@ public class Execute {
cmd[0] = "env";
}
return cmd;
- } else if (Os.isFamily("netware") || Os.isFamily("os/400")) {
+ }
+ if (Os.isFamily("netware") || Os.isFamily("os/400")) {
// rely on PATH
- return new String[] {"env"};
- } else if (Os.isFamily("openvms")) {
- return new String[] {"show", "logical"};
- } else {
- // MAC OS 9 and previous
- // TODO: I have no idea how to get it, someone must fix it
- return null;
+ return new String[] { "env" };
+ }
+ if (Os.isFamily("openvms")) {
+ return new String[] { "show", "logical" };
}
+ // MAC OS 9 and previous
+ // TODO: I have no idea how to get it, someone must fix it
+ return null;
}
/**
@@ -244,13 +246,13 @@ public class Execute {
if (Os.isFamily("z/os")) {
try {
return bos.toString("Cp1047");
- } catch (java.io.UnsupportedEncodingException e) {
+ } catch (UnsupportedEncodingException e) {
// noop default encoding used
}
} else if (Os.isFamily("os/400")) {
try {
return bos.toString("Cp500");
- } catch (java.io.UnsupportedEncodingException e) {
+ } catch (UnsupportedEncodingException e) {
// noop default encoding used
}
}
@@ -417,7 +419,7 @@ public class Execute {
String[] env, File dir, boolean useVM)
throws IOException {
if (dir != null && !dir.exists()) {
- throw new BuildException(dir + " doesn't exist.");
+ throw new BuildException("%s doesn't exist.", dir);
}
CommandLauncher vmLauncher = CommandLauncher.getVMLauncher(project);
@@ -435,7 +437,7 @@ public class Execute {
*/
public int execute() throws IOException {
if (workingDirectory != null && !workingDirectory.exists()) {
- throw new BuildException(workingDirectory + " doesn't exist.");
+ throw new BuildException("%s doesn't exist.", workingDirectory);
}
final Process process = launch(project, getCommandline(),
getEnvironment(), workingDirectory,
@@ -492,7 +494,7 @@ public class Execute {
*/
public void spawn() throws IOException {
if (workingDirectory != null && !workingDirectory.exists()) {
- throw new BuildException(workingDirectory + " doesn't exist.");
+ throw new BuildException("%s doesn't exist.", workingDirectory);
}
final Process process = launch(project, getCommandline(),
getEnvironment(), workingDirectory,
@@ -611,7 +613,7 @@ public class Execute {
return env;
}
Map<String, String> osEnv =
- new LinkedHashMap<String, String>(getEnvironmentVariables());
+ new LinkedHashMap<>(getEnvironmentVariables());
for (int i = 0; i < env.length; i++) {
String keyValue = env[i];
String key = keyValue.substring(0, keyValue.indexOf('='));
@@ -624,7 +626,7 @@ public class Execute {
for (String osEnvItem : osEnv.keySet()) {
// Nb: using default locale as key is a env name
- if (osEnvItem.toLowerCase().equals(key.toLowerCase())) {
+ if (osEnvItem.equalsIgnoreCase(key)) {
// Use the original casiness of the key
key = osEnvItem;
break;
@@ -636,11 +638,8 @@ public class Execute {
osEnv.put(key, keyValue.substring(key.length() + 1));
}
- ArrayList<String> l = new ArrayList<String>();
- for (Entry<String, String> entry : osEnv.entrySet()) {
- l.add(entry.getKey() + "=" + entry.getValue());
- }
- return l.toArray(new String[osEnv.size()]);
+ return osEnv.entrySet().stream()
+ .map(e -> e.getKey() + "=" + e.getValue()).toArray(String[]::new);
}
/**
@@ -651,7 +650,7 @@ public class Execute {
* @param cmdline The command to execute.
* @throws BuildException if the command does not exit successfully.
*/
- public static void runCommand(Task task, String[] cmdline)
+ public static void runCommand(Task task, String... cmdline)
throws BuildException {
try {
task.log(Commandline.describeCommand(cmdline),
@@ -665,7 +664,7 @@ public class Execute {
throw new BuildException(cmdline[0]
+ " failed with return code " + retval, task.getLocation());
}
- } catch (java.io.IOException exc) {
+ } catch (IOException exc) {
throw new BuildException("Could not launch " + cmdline[0] + ": "
+ exc, task.getLocation());
}
@@ -695,9 +694,9 @@ public class Execute {
*/
private static Map<String, String> getVMSLogicals(BufferedReader in)
throws IOException {
- HashMap<String, String> logicals = new HashMap<String, String>();
+ Map<String, String> logicals = new HashMap<>();
String logName = null, logValue = null, newLogName;
- String line = null;
+ String line;
// CheckStyle:MagicNumber OFF
while ((line = in.readLine()) != null) {
// parse the VMS logicals into required format ("VAR=VAL[,VAL2]")
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
index b36f2fe..e034cea 100644
--- a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
+++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
@@ -97,6 +97,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
* @deprecated since 1.4.x.
* manage output at the task level.
*/
+ @Deprecated
public void setOutput(PrintStream out) {
}
@@ -122,7 +123,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
if (sysProperties != null) {
sysProperties.setSystem();
}
- Class<?> target = null;
+ Class<?> target;
try {
if (classpath == null) {
target = Class.forName(classname);
@@ -137,18 +138,18 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
target = Class.forName(classname, true, loader);
}
} catch (ClassNotFoundException e) {
- throw new BuildException("Could not find " + classname + "."
- + " Make sure you have it in your"
- + " classpath");
+ throw new BuildException(
+ "Could not find %s. Make sure you have it in your classpath",
+ classname);
}
main = target.getMethod("main", new Class[] {String[].class});
if (main == null) {
- throw new BuildException("Could not find main() method in "
- + classname);
+ throw new BuildException("Could not find main() method in %s",
+ classname);
}
if ((main.getModifiers() & Modifier.STATIC) == 0) {
- throw new BuildException("main() method in " + classname
- + " is not declared static");
+ throw new BuildException(
+ "main() method in %s is not declared static", classname);
}
if (timeout == null) {
run(); //NOSONAR
@@ -212,6 +213,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
* Run this ExecuteJava in a Thread.
* @since Ant 1.5
*/
+ @Override
public void run() {
final Object[] argument = {javaCommand.getArguments()};
try {
@@ -242,6 +244,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
* @param w the responsible Watchdog.
* @since Ant 1.5
*/
+ @Override
public synchronized void timeoutOccured(Watchdog w) {
if (thread != null) {
timedOut = true;
@@ -318,7 +321,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
exe.setVMLauncher(true);
File vmsJavaOptionFile = null;
try {
- String [] args = new String[command.length - 1];
+ String[] args = new String[command.length - 1];
System.arraycopy(command, 1, args, 0, command.length - 1);
vmsJavaOptionFile = JavaEnvUtils.createVmsJavaOptionFile(args);
//we mark the file to be deleted on exit.
@@ -326,7 +329,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
//after execution finished, which is much better for long-lived runtimes
//though spawning complicates things...
vmsJavaOptionFile.deleteOnExit();
- String [] vmsCmd = {command[0], "-V", vmsJavaOptionFile.getPath()};
+ String[] vmsCmd = { command[0], "-V", vmsJavaOptionFile.getPath() };
exe.setCommandline(vmsCmd);
} catch (IOException e) {
throw new BuildException("Failed to create a temporary file for \"-V\" switch");
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
index 18cbd29..b9decc3 100644
--- a/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
+++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
@@ -20,7 +20,10 @@ package org.apache.tools.ant.taskdefs;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
@@ -60,8 +63,9 @@ public class ExecuteOn extends ExecTask {
// switching type to "dir" when we encounter a DirSet that would
// be more difficult to achieve otherwise.
- protected Vector<AbstractFileSet> filesets = new Vector<AbstractFileSet>(); // contains AbstractFileSet
- // (both DirSet and FileSet)
+ // (both DirSet and FileSet)
+ protected Vector<AbstractFileSet> filesets = new Vector<>();
+
private Union resources = null;
private boolean relative = false;
private boolean parallel = false;
@@ -296,6 +300,7 @@ public class ExecuteOn extends ExecTask {
/**
* Check the configuration of this ExecuteOn instance.
*/
+ @Override
protected void checkConfiguration() {
// * @TODO using taskName here is brittle, as a user could override it.
// * this should probably be modified to use the classname instead.
@@ -303,7 +308,7 @@ public class ExecuteOn extends ExecTask {
log("!! execon is deprecated. Use apply instead. !!");
}
super.checkConfiguration();
- if (filesets.size() == 0 && resources == null) {
+ if (filesets.isEmpty() && resources == null) {
throw new BuildException("no resources specified",
getLocation());
}
@@ -326,6 +331,7 @@ public class ExecuteOn extends ExecTask {
* @return <code>ExecuteStreamHandler</code>.
* @throws BuildException on error.
*/
+ @Override
protected ExecuteStreamHandler createHandler() throws BuildException {
//if we have a RedirectorElement, return a decoy
return (redirectorElement == null)
@@ -335,6 +341,7 @@ public class ExecuteOn extends ExecTask {
/**
* Set up the I/O Redirector.
*/
+ @Override
protected void setupRedirector() {
super.setupRedirector();
redirector.setAppendProperties(true);
@@ -345,23 +352,21 @@ public class ExecuteOn extends ExecTask {
* @param exe the Execute instance representing the external process.
* @throws BuildException on error
*/
+ @Override
protected void runExec(Execute exe) throws BuildException {
int totalFiles = 0;
int totalDirs = 0;
boolean haveExecuted = false;
try {
- Vector<String> fileNames = new Vector<String>();
- Vector<File> baseDirs = new Vector<File>();
- final int size = filesets.size();
- for (int i = 0; i < size; i++) {
+ Vector<String> fileNames = new Vector<>();
+ Vector<File> baseDirs = new Vector<>();
+ for (AbstractFileSet fs : filesets) {
String currentType = type;
- AbstractFileSet fs = filesets.elementAt(i);
if (fs instanceof DirSet) {
if (!FileDirBoth.DIR.equals(type)) {
log("Found a nested dirset but type is " + type + ". "
- + "Temporarily switching to type=\"dir\" on the"
- + " assumption that you really did mean"
- + " <dirset> not <fileset>.", Project.MSG_DEBUG);
+ + "Temporarily switching to type=\"dir\" on the assumption that you really did mean <dirset> not <fileset>.",
+ Project.MSG_DEBUG);
currentType = FileDirBoth.DIR;
}
}
@@ -373,34 +378,32 @@ public class ExecuteOn extends ExecTask {
String[] s = getFiles(base, ds);
for (int j = 0; j < s.length; j++) {
totalFiles++;
- fileNames.addElement(s[j]);
- baseDirs.addElement(base);
+ fileNames.add(s[j]);
+ baseDirs.add(base);
}
}
if (!FileDirBoth.FILE.equals(currentType)) {
String[] s = getDirs(base, ds);
for (int j = 0; j < s.length; j++) {
totalDirs++;
- fileNames.addElement(s[j]);
- baseDirs.addElement(base);
+ fileNames.add(s[j]);
+ baseDirs.add(base);
}
}
- if (fileNames.size() == 0 && skipEmpty) {
+ if (fileNames.isEmpty() && skipEmpty) {
logSkippingFileset(currentType, ds, base);
continue;
}
if (!parallel) {
- String[] s = new String[fileNames.size()];
- fileNames.copyInto(s);
- for (int j = 0; j < s.length; j++) {
- String[] command = getCommandline(s[j], base);
+ for (String srcFile : fileNames) {
+ String[] command = getCommandline(srcFile, base);
log(Commandline.describeCommand(command),
Project.MSG_VERBOSE);
exe.setCommandline(command);
if (redirectorElement != null) {
setupRedirector();
- redirectorElement.configure(redirector, s[j]);
+ redirectorElement.configure(redirector, srcFile);
}
if (redirectorElement != null || haveExecuted) {
// need to reset the stream handler to restart
@@ -411,8 +414,8 @@ public class ExecuteOn extends ExecTask {
runExecute(exe);
haveExecuted = true;
}
- fileNames.removeAllElements();
- baseDirs.removeAllElements();
+ fileNames.clear();
+ baseDirs.clear();
}
}
@@ -469,12 +472,12 @@ public class ExecuteOn extends ExecTask {
}
runExecute(exe);
haveExecuted = true;
- fileNames.removeAllElements();
- baseDirs.removeAllElements();
+ fileNames.clear();
+ baseDirs.clear();
}
}
}
- if (parallel && (fileNames.size() > 0 || !skipEmpty)) {
+ if (parallel && (!fileNames.isEmpty() || !skipEmpty)) {
runParallel(exe, fileNames, baseDirs);
haveExecuted = true;
}
@@ -524,31 +527,31 @@ public class ExecuteOn extends ExecTask {
*/
protected String[] getCommandline(String[] srcFiles, File[] baseDirs) {
final char fileSeparator = File.separatorChar;
- Vector<String> targets = new Vector<String>();
+ List<String> targets = new ArrayList<>();
if (targetFilePos != null) {
- HashSet<String> addedFiles = new HashSet<String>();
+ Set<String> addedFiles = new HashSet<>();
for (int i = 0; i < srcFiles.length; i++) {
String[] subTargets = mapper.mapFileName(srcFiles[i]);
if (subTargets != null) {
- for (int j = 0; j < subTargets.length; j++) {
- String name = null;
- if (!relative) {
- name = new File(destDir, subTargets[j]).getAbsolutePath();
+ for (String subTarget : subTargets) {
+ String name;
+ if (relative) {
+ name = subTarget;
} else {
- name = subTargets[j];
+ name = new File(destDir, subTarget).getAbsolutePath();
}
if (forwardSlash && fileSeparator != '/') {
name = name.replace(fileSeparator, '/');
}
if (!addedFiles.contains(name)) {
- targets.addElement(name);
+ targets.add(name);
addedFiles.add(name);
}
}
}
}
}
- String[] targetFiles = (String[]) targets.toArray(new String[targets.size()]);
+ String[] targetFiles = targets.toArray(new String[targets.size()]);
if (!addSourceFile) {
srcFiles = new String[0];
@@ -642,7 +645,7 @@ public class ExecuteOn extends ExecTask {
* @return the command line in the form of a String[].
*/
protected String[] getCommandline(String srcFile, File baseDir) {
- return getCommandline(new String[] {srcFile}, new File[] {baseDir});
+ return getCommandline(new String[] { srcFile }, new File[] { baseDir });
}
/**
@@ -697,10 +700,8 @@ public class ExecuteOn extends ExecTask {
protected void runParallel(Execute exe, Vector<String> fileNames,
Vector<File> baseDirs)
throws IOException, BuildException {
- String[] s = new String[fileNames.size()];
- fileNames.copyInto(s);
- File[] b = new File[baseDirs.size()];
- baseDirs.copyInto(b);
+ String[] s = fileNames.toArray(new String[fileNames.size()]);
+ File[] b = baseDirs.toArray(new File[baseDirs.size()]);
if (maxParallel <= 0
|| s.length == 0 /* this is skipEmpty == false */) {
@@ -752,7 +753,7 @@ public class ExecuteOn extends ExecTask {
String[] arguments,
int insertPosition,
String prefix, String suffix) {
- if (prefix.length() == 0 && suffix.length() == 0) {
+ if (prefix.isEmpty() && suffix.isEmpty()) {
System.arraycopy(targetFiles, 0, arguments, insertPosition,
targetFiles.length);
} else {
@@ -772,12 +773,14 @@ public class ExecuteOn extends ExecTask {
public static final String FILE = "file";
/** Dir value */
public static final String DIR = "dir";
+
/**
+ * {@inheritDoc}
* @see EnumeratedAttribute#getValues
*/
- /** {@inheritDoc}. */
- public String[] getValues() {
- return new String[] {FILE, DIR, "both"};
+ @Override
+ public String[] getValues() {
+ return new String[] { FILE, DIR, "both" };
}
}
http://git-wip-us.apache.org/repos/asf/ant/blob/b7d1e9bd/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java
index cc3933e..4925f54 100644
--- a/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java
+++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteWatchdog.java
@@ -74,6 +74,7 @@ public class ExecuteWatchdog implements TimeoutObserver {
* Use constructor with a long type instead.
* (1.4.x compatibility)
*/
+ @Deprecated
public ExecuteWatchdog(int timeout) {
this((long) timeout);
}
@@ -112,6 +113,7 @@ public class ExecuteWatchdog implements TimeoutObserver {
* This can be called in the watchdog thread
* @param w the watchdog
*/
+ @Override
public synchronized void timeoutOccured(Watchdog w) {
try {
try {
@@ -174,4 +176,3 @@ public class ExecuteWatchdog implements TimeoutObserver {
return killedProcess;
}
}
-