git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274945 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -65,7 +65,6 @@ import org.apache.tools.ant.BuildException; | |||
| import org.apache.tools.ant.Location; | |||
| import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.Target; | |||
| import org.apache.tools.ant.helper.ProjectHelper2; | |||
| import org.apache.tools.ant.UnknownElement; | |||
| @@ -104,13 +103,13 @@ public class Antlib extends Task implements TaskContainer { | |||
| // Should be safe to parse | |||
| try { | |||
| ProjectHelper2 parser = new ProjectHelper2(); | |||
| UnknownElement ue = | |||
| UnknownElement ue = | |||
| parser.parseUnknownElement(project, antlibUrl); | |||
| // Check name is "antlib" | |||
| if (!(ue.getTag().equals(TAG))) { | |||
| throw new BuildException( | |||
| "Unexpected tag " + ue.getTag() + " expecting " + | |||
| TAG, ue.getLocation()); | |||
| "Unexpected tag " + ue.getTag() + " expecting " | |||
| + TAG, ue.getLocation()); | |||
| } | |||
| Antlib antlib = new Antlib(); | |||
| antlib.setProject(project); | |||
| @@ -101,6 +101,9 @@ import org.apache.tools.ant.util.FileUtils; | |||
| * @author Peter Reilly | |||
| */ | |||
| public class Concat extends Task { | |||
| // The size of buffers to be used | |||
| private static final int BUFFER_SIZE = 8192; | |||
| // Attributes. | |||
| @@ -442,7 +445,7 @@ public class Concat extends Task { | |||
| private void cat() { | |||
| OutputStream os = null; | |||
| Reader reader = null; | |||
| char[] buffer = new char[8192]; | |||
| char[] buffer = new char[BUFFER_SIZE]; | |||
| try { | |||
| @@ -535,7 +538,7 @@ public class Concat extends Task { | |||
| throws IOException { | |||
| if (filterChains != null) { | |||
| ChainReaderHelper helper = new ChainReaderHelper(); | |||
| helper.setBufferSize(8192); | |||
| helper.setBufferSize(BUFFER_SIZE); | |||
| helper.setPrimaryReader(in); | |||
| helper.setFilterChains(filterChains); | |||
| helper.setProject(getProject()); | |||
| @@ -100,6 +100,7 @@ import org.apache.tools.ant.types.selectors.FileSelector; | |||
| * @ant.task category="filesystem" | |||
| */ | |||
| public class Delete extends MatchingTask { | |||
| private static final int DELETE_RETRY_SLEEP_MILLIS = 10; | |||
| protected File file = null; | |||
| protected File dir = null; | |||
| protected Vector filesets = new Vector(); | |||
| @@ -170,20 +171,24 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * If true, delete empty directories. | |||
| * @param includeEmpty if true delete empty directories (only | |||
| * for filesets). Default is false. | |||
| */ | |||
| public void setIncludeEmptyDirs(boolean includeEmpty) { | |||
| this.includeEmpty = includeEmpty; | |||
| } | |||
| /** | |||
| * Adds a 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); | |||
| } | |||
| /** | |||
| * add a name entry on the include list | |||
| * @return a NameEntry object to be configured | |||
| */ | |||
| public PatternSet.NameEntry createInclude() { | |||
| usedMatchingTask = true; | |||
| @@ -192,6 +197,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a name entry on the include files list | |||
| * @return an NameEntry object to be configured | |||
| */ | |||
| public PatternSet.NameEntry createIncludesFile() { | |||
| usedMatchingTask = true; | |||
| @@ -200,6 +206,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a name entry on the exclude list | |||
| * @return an NameEntry object to be configured | |||
| */ | |||
| public PatternSet.NameEntry createExclude() { | |||
| usedMatchingTask = true; | |||
| @@ -208,6 +215,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a name entry on the include files list | |||
| * @return an NameEntry object to be configured | |||
| */ | |||
| public PatternSet.NameEntry createExcludesFile() { | |||
| usedMatchingTask = true; | |||
| @@ -216,6 +224,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a set of patterns | |||
| * @return PatternSet object to be configured | |||
| */ | |||
| public PatternSet createPatternSet() { | |||
| usedMatchingTask = true; | |||
| @@ -301,6 +310,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a "Select" selector entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addSelector(SelectSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -309,6 +319,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add an "And" selector entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addAnd(AndSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -317,6 +328,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add an "Or" selector entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addOr(OrSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -325,6 +337,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a "Not" selector entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addNot(NotSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -333,6 +346,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a "None" selector entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addNone(NoneSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -341,6 +355,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a majority selector entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addMajority(MajoritySelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -349,6 +364,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a selector date entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addDate(DateSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -357,6 +373,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a selector size entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addSize(SizeSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -365,6 +382,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a selector filename entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addFilename(FilenameSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -373,6 +391,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add an extended selector entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addCustom(ExtendSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -381,6 +400,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a contains selector entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addContains(ContainsSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -389,6 +409,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a present selector entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addPresent(PresentSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -397,6 +418,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a depth selector entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addDepth(DepthSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -405,6 +427,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a depends selector entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addDepend(DependSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -413,6 +436,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add a regular expression selector entry on the selector list | |||
| * @param selector the selector to be added | |||
| */ | |||
| public void addContainsRegexp(ContainsRegexpSelector selector) { | |||
| usedMatchingTask = true; | |||
| @@ -421,6 +445,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * add an arbitary selector | |||
| * @param selector the selector to be added | |||
| * @since Ant 1.6 | |||
| */ | |||
| public void add(FileSelector selector) { | |||
| @@ -430,6 +455,7 @@ public class Delete extends MatchingTask { | |||
| /** | |||
| * Delete the file(s). | |||
| * @exception BuildException if an error occurs | |||
| */ | |||
| public void execute() throws BuildException { | |||
| if (usedMatchingTask) { | |||
| @@ -542,7 +568,7 @@ public class Delete extends MatchingTask { | |||
| private boolean delete(File f) { | |||
| if (!f.delete()) { | |||
| try { | |||
| Thread.sleep(10); | |||
| Thread.sleep(DELETE_RETRY_SLEEP_MILLIS); | |||
| return f.delete(); | |||
| } catch (InterruptedException ex) { | |||
| return f.delete(); | |||
| @@ -551,6 +577,11 @@ public class Delete extends MatchingTask { | |||
| return true; | |||
| } | |||
| /** | |||
| * Delete a directory | |||
| * | |||
| * @param d the directory to delete | |||
| */ | |||
| protected void removeDir(File d) { | |||
| String[] list = d.list(); | |||
| if (list == null) { | |||
| @@ -111,6 +111,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer { | |||
| /** | |||
| * add a name entry on the include list | |||
| * @return a NameEntry object to be configured | |||
| */ | |||
| public PatternSet.NameEntry createInclude() { | |||
| return fileset.createInclude(); | |||
| @@ -118,6 +119,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer { | |||
| /** | |||
| * add a name entry on the include files list | |||
| * @return an NameEntry object to be configured | |||
| */ | |||
| public PatternSet.NameEntry createIncludesFile() { | |||
| return fileset.createIncludesFile(); | |||
| @@ -125,6 +127,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer { | |||
| /** | |||
| * add a name entry on the exclude list | |||
| * @return an NameEntry object to be configured | |||
| */ | |||
| public PatternSet.NameEntry createExclude() { | |||
| return fileset.createExclude(); | |||
| @@ -132,6 +135,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer { | |||
| /** | |||
| * add a name entry on the include files list | |||
| * @return an NameEntry object to be configured | |||
| */ | |||
| public PatternSet.NameEntry createExcludesFile() { | |||
| return fileset.createExcludesFile(); | |||
| @@ -139,6 +143,7 @@ public abstract class MatchingTask extends Task implements SelectorContainer { | |||
| /** | |||
| * add a set of patterns | |||
| * @return PatternSet object to be configured | |||
| */ | |||
| public PatternSet createPatternSet() { | |||
| return fileset.createPatternSet(); | |||
| @@ -250,7 +250,7 @@ public class Parallel extends Task | |||
| public synchronized void run() { | |||
| try { | |||
| wait(timeout); | |||
| synchronized(semaphore) { | |||
| synchronized (semaphore) { | |||
| stillRunning = false; | |||
| timedOut = true; | |||
| semaphore.notifyAll(); | |||
| @@ -290,7 +290,7 @@ public class Parallel extends Task | |||
| } | |||
| } | |||
| synchronized(semaphore) { | |||
| synchronized (semaphore) { | |||
| // are all threads finished | |||
| outer2: | |||
| while (stillRunning) { | |||
| @@ -318,7 +318,7 @@ public class Parallel extends Task | |||
| StringBuffer exceptionMessage = new StringBuffer(); | |||
| int numExceptions = 0; | |||
| Throwable firstException = null; | |||
| Location firstLocation = Location.UNKNOWN_LOCATION;; | |||
| Location firstLocation = Location.UNKNOWN_LOCATION; | |||
| for (int i = 0; i < numTasks; ++i) { | |||
| Throwable t = runnables[i].getException(); | |||
| if (t != null) { | |||
| @@ -80,6 +80,7 @@ public class Patch extends Task { | |||
| /** | |||
| * The file to patch; optional if it can be inferred from | |||
| * the diff file | |||
| * @param file the file to patch | |||
| */ | |||
| public void setOriginalfile(File file) { | |||
| originalFile = file; | |||
| @@ -88,7 +89,7 @@ public class Patch extends Task { | |||
| /** | |||
| * The name of a file to send the output to, instead of patching | |||
| * the file(s) in place; optional. | |||
| * | |||
| * @param file the file to send the output to | |||
| * @since Ant 1.6 | |||
| */ | |||
| public void setDestfile(File file) { | |||
| @@ -100,6 +101,7 @@ public class Patch extends Task { | |||
| /** | |||
| * The file containing the diff output; required. | |||
| * @param file the file containing the diff output | |||
| */ | |||
| public void setPatchfile(File file) { | |||
| if (!file.exists()) { | |||
| @@ -113,6 +115,7 @@ public class Patch extends Task { | |||
| /** | |||
| * flag to create backups; optional, default=false | |||
| * @param backups if true create backups | |||
| */ | |||
| public void setBackups(boolean backups) { | |||
| if (backups) { | |||
| @@ -122,6 +125,7 @@ public class Patch extends Task { | |||
| /** | |||
| * flag to ignore whitespace differences; default=false | |||
| * @param ignore if true ignore whitespace differences | |||
| */ | |||
| public void setIgnorewhitespace(boolean ignore) { | |||
| if (ignore) { | |||
| @@ -135,6 +139,7 @@ public class Patch extends Task { | |||
| * | |||
| * <p>patch's <i>-p</i> option. | |||
| * @param num number of lines to strip | |||
| * @exception BuildException if num is < 0, or other errors | |||
| */ | |||
| public void setStrip(int num) throws BuildException { | |||
| if (num < 0) { | |||
| @@ -145,6 +150,7 @@ public class Patch extends Task { | |||
| /** | |||
| * Work silently unless an error occurs; optional, default=false | |||
| * @param q if true supress set the -s option on the patch command | |||
| */ | |||
| public void setQuiet(boolean q) { | |||
| if (q) { | |||
| @@ -155,6 +161,7 @@ public class Patch extends Task { | |||
| /** | |||
| * Assume patch was created with old and new files swapped; optional, | |||
| * default=false | |||
| * @param r if true set the -R option on the patch command | |||
| */ | |||
| public void setReverse(boolean r) { | |||
| if (r) { | |||
| @@ -165,10 +172,10 @@ public class Patch extends Task { | |||
| /** | |||
| * The directory to run the patch command in, defaults to the | |||
| * project's base directory. | |||
| * | |||
| * @param directory the directory to run the patch command in | |||
| * @since Ant 1.5 | |||
| */ | |||
| public void setDir(File directory) throws BuildException { | |||
| public void setDir(File directory) { | |||
| this.directory = directory; | |||
| } | |||
| @@ -119,10 +119,18 @@ public class Replace extends MatchingTask { | |||
| private StringBuffer buf = new StringBuffer(); | |||
| /** | |||
| * the text of the element | |||
| * | |||
| * @param val the string to add | |||
| */ | |||
| public void addText(String val) { | |||
| buf.append(val); | |||
| } | |||
| /** | |||
| * @return the text | |||
| */ | |||
| public String getText() { | |||
| return buf.substring(0); | |||
| } | |||
| @@ -183,6 +191,7 @@ public class Replace extends MatchingTask { | |||
| /** | |||
| * Get the replacement value for this filter token. | |||
| * @return the replacement value | |||
| */ | |||
| public String getReplaceValue() { | |||
| if (property != null) { | |||
| @@ -352,7 +361,7 @@ public class Replace extends MatchingTask { | |||
| /** | |||
| * helper method to load a properties file and throw a build exception | |||
| * if it cannot be loaded | |||
| * @param propertyFile | |||
| * @param propertyFile the file to load the properties from | |||
| * @return loaded properties collection | |||
| * @throws BuildException if the file could not be found or read | |||
| */ | |||
| @@ -600,6 +609,7 @@ public class Replace extends MatchingTask { | |||
| /** | |||
| * Add a nested <replacefilter> element. | |||
| * @return a nested ReplaceFilter object to be configured | |||
| */ | |||
| public Replacefilter createReplacefilter() { | |||
| Replacefilter filter = new Replacefilter(); | |||
| @@ -71,7 +71,7 @@ public class DotnetDefine { | |||
| /** | |||
| * the name of a property which must be defined for | |||
| * the definition to be set. Optional. | |||
| * @param condition | |||
| * @param condition the name of the property | |||
| */ | |||
| public void setIf(String condition) { | |||
| this.ifCond = condition; | |||
| @@ -80,7 +80,7 @@ public class DotnetDefine { | |||
| /** | |||
| * the name of a property which must be undefined for | |||
| * the definition to be set. Optional. | |||
| * @param condition | |||
| * @param condition the name of the property | |||
| */ | |||
| public void setUnless(String condition) { | |||
| this.unlessCond = condition; | |||