diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java index 529ae15bf..232efb19c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copy.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java @@ -773,14 +773,13 @@ public class Copy extends Task { final FileNameMapper mapper, final Hashtable map) { String[] toCopy = null; if (forceOverwrite) { - final Vector v = new Vector<>(); + final List v = new ArrayList(); for (String name : names) { if (mapper.mapFileName(name) != null) { - v.addElement(name); + v.add(name); } } - toCopy = new String[v.size()]; - v.copyInto(toCopy); + toCopy = v.toArray(new String[v.size()]); } else { final SourceFileScanner ds = new SourceFileScanner(this); toCopy = ds.restrict(names, fromDir, toDir, mapper, granularity); diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index 2352459ea..1ca9dad6d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -1908,14 +1908,12 @@ public class Javadoc extends Task { private void doDoclet(final Commandline toExecute) { if (doclet != null) { if (doclet.getName() == null) { - throw new BuildException("The doclet name must be specified.", - getLocation()); + throw new BuildException("The doclet name must be specified.", getLocation()); } toExecute.createArgument().setValue("-doclet"); toExecute.createArgument().setValue(doclet.getName()); if (doclet.getPath() != null) { - final Path docletPath - = doclet.getPath().concatSystemClasspath("ignore"); + final Path docletPath = doclet.getPath().concatSystemClasspath("ignore"); if (docletPath.size() != 0) { toExecute.createArgument().setValue("-docletpath"); toExecute.createArgument().setPath(docletPath); @@ -1925,7 +1923,6 @@ public class Javadoc extends Task { if (param.getName() == null) { throw new BuildException("Doclet parameters must have a name"); } - toExecute.createArgument().setValue(param.getName()); if (param.getValue() != null) { toExecute.createArgument().setValue(param.getValue()); @@ -2120,20 +2117,15 @@ public class Javadoc extends Task { ta.getDirectoryScanner(getProject()); for (String file : tagDefScanner.getIncludedFiles()) { final File tagDefFile = new File(tagDir, file); - try (final BufferedReader in = - new BufferedReader(new FileReader(tagDefFile))) { - String line; - while ((line = in.readLine()) != null) { - toExecute.createArgument() - .setValue("-tag"); - toExecute.createArgument() - .setValue(line); - } + try (final BufferedReader in = new BufferedReader( + new FileReader(tagDefFile))) { + in.lines().forEach(line -> { + toExecute.createArgument().setValue("-tag"); + toExecute.createArgument().setValue(line); + }); } catch (final IOException ioe) { - throw new BuildException( - "Couldn't read tag file from " - + tagDefFile.getAbsolutePath(), - ioe); + throw new BuildException("Couldn't read tag file from " + + tagDefFile.getAbsolutePath(), ioe); } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Untar.java b/src/main/org/apache/tools/ant/taskdefs/Untar.java index d1845f0f9..8221dadbb 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Untar.java +++ b/src/main/org/apache/tools/ant/taskdefs/Untar.java @@ -218,9 +218,8 @@ public class Untar extends Expand { * @exception BuildException thrown if bzip stream does not * start with expected magic values */ - public InputStream decompress(final String name, - final InputStream istream) - throws IOException, BuildException { + public InputStream decompress(final String name, final InputStream istream) + throws IOException, BuildException { final String v = getValue(); if (GZIP.equals(v)) { return new GZIPInputStream(istream); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java index f72da99b1..8b80cb8a3 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java @@ -478,12 +478,11 @@ public class Depend extends MatchingTask { // without closure we may delete an inner class but not the // top level class which would not trigger a recompile. - int aci = affectedClass.indexOf('$'); - if (aci == -1) { + if (!affectedClass.contains("$")) { continue; } // need to delete the main class - String topLevelClassName = affectedClass.substring(0, aci); + String topLevelClassName = affectedClass.substring(0, affectedClass.indexOf("$")); log("Top level class = " + topLevelClassName, Project.MSG_VERBOSE); ClassFileInfo topLevelClassInfo diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java index 9f1f4525c..df54e92ff 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java @@ -42,7 +42,6 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; - /** * Aggregates all <junit> XML formatter testsuite data under * a specific directory and transforms the results via XSLT. diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java index c378b21e0..0d877aaec 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java @@ -476,9 +476,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { * @param fast boolean */ private void accountForIncludedDir(String name, AntFTPFile file, boolean fast) { - if (!dirsIncluded.contains(name) - && !dirsExcluded.contains(name)) { - + if (!dirsIncluded.contains(name) && !dirsExcluded.contains(name)) { if (!isExcluded(name)) { if (fast) { if (file.isSymbolicLink()) { @@ -724,16 +722,14 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { } this.curpwd = parent.getAbsolutePath(); } catch (IOException ioe) { - throw new BuildException( - "could not change working dir to %s", parent.curpwd); + throw new BuildException("could not change working dir to %s", parent.curpwd); } for (String currentPathElement : pathElements) { try { if (!this.client.changeWorkingDirectory(currentPathElement)) { if (!isCaseSensitive() && (remoteSystemCaseSensitive - || !remoteSensitivityChecked)) { - currentPathElement = - findPathElementCaseUnsensitive(this.curpwd, + || !remoteSensitivityChecked)) { + currentPathElement = findPathElementCaseUnsensitive(this.curpwd, currentPathElement); if (currentPathElement == null) { return; @@ -741,12 +737,10 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { } return; } - this.curpwd = - getCurpwdPlusFileSep() + currentPathElement; + this.curpwd = getCurpwdPlusFileSep() + currentPathElement; } catch (IOException ioe) { - throw new BuildException( - "could not change working dir to %s from %s", - currentPathElement, this.curpwd); + throw new BuildException("could not change working dir to %s from %s", + currentPathElement, this.curpwd); } } String lastpathelement = pathElements.get(pathElements.size() - 1); diff --git a/src/main/org/apache/tools/ant/types/Commandline.java b/src/main/org/apache/tools/ant/types/Commandline.java index 81440fad6..4653c7755 100644 --- a/src/main/org/apache/tools/ant/types/Commandline.java +++ b/src/main/org/apache/tools/ant/types/Commandline.java @@ -430,8 +430,8 @@ public class Commandline implements Cloneable { return '\'' + argument + '\''; } if (argument.contains("\'") || argument.contains(" ") - // WIN9x uses a bat file for executing commands - || (IS_WIN_9X && argument.contains(";"))) { + // WIN9x uses a bat file for executing commands + || (IS_WIN_9X && argument.contains(";"))) { return '\"' + argument + '\"'; } return argument; diff --git a/src/main/org/apache/tools/ant/types/FilterSet.java b/src/main/org/apache/tools/ant/types/FilterSet.java index 7d3333d78..1e47afa48 100644 --- a/src/main/org/apache/tools/ant/types/FilterSet.java +++ b/src/main/org/apache/tools/ant/types/FilterSet.java @@ -593,8 +593,7 @@ public class FilterSet extends DataType implements Cloneable { } passedTokens.addElement(parent); String value = iReplaceTokens(line); - if (!value.contains(beginToken) && !duplicateToken - && recurseDepth == 1) { + if (!value.contains(beginToken) && !duplicateToken && recurseDepth == 1) { passedTokens = null; } else if (duplicateToken) { // should always be the case...