git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274934 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -90,6 +90,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| * setCompression( true ). | * setCompression( true ). | ||||
| */ | */ | ||||
| public static final int DEFAULT_COMPRESSION_LEVEL = 3; | public static final int DEFAULT_COMPRESSION_LEVEL = 3; | ||||
| private static final int MAXIMUM_COMRESSION_LEVEL = 9; | |||||
| private Commandline cmd = new Commandline(); | private Commandline cmd = new Commandline(); | ||||
| @@ -114,7 +115,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * the default command. | * the default command. | ||||
| */ | */ | ||||
| private static final String default_command = "checkout"; | |||||
| private static final String DEFAULT_COMMAND = "checkout"; | |||||
| /** | /** | ||||
| * the CVS command to execute. | * the CVS command to execute. | ||||
| */ | */ | ||||
| @@ -182,10 +183,18 @@ public abstract class AbstractCvsTask extends Task { | |||||
| super(); | super(); | ||||
| } | } | ||||
| /** | |||||
| * sets the handler | |||||
| * @param handler a handler able of processing the output and error streams from the cvs exe | |||||
| */ | |||||
| public void setExecuteStreamHandler(ExecuteStreamHandler handler) { | public void setExecuteStreamHandler(ExecuteStreamHandler handler) { | ||||
| this.executeStreamHandler = handler; | this.executeStreamHandler = handler; | ||||
| } | } | ||||
| /** | |||||
| * find the handler and instantiate it if it does not exist yet | |||||
| * @return handler for output and error streams | |||||
| */ | |||||
| protected ExecuteStreamHandler getExecuteStreamHandler() { | protected ExecuteStreamHandler getExecuteStreamHandler() { | ||||
| if (this.executeStreamHandler == null) { | if (this.executeStreamHandler == null) { | ||||
| @@ -196,12 +205,23 @@ public abstract class AbstractCvsTask extends Task { | |||||
| return this.executeStreamHandler; | return this.executeStreamHandler; | ||||
| } | } | ||||
| /** | |||||
| * sets a stream to which the output from the cvs executable should be sent | |||||
| * @param outputStream stream to which the stdout from cvs should go | |||||
| */ | |||||
| protected void setOutputStream(OutputStream outputStream) { | protected void setOutputStream(OutputStream outputStream) { | ||||
| this.outputStream = outputStream; | this.outputStream = outputStream; | ||||
| } | } | ||||
| /** | |||||
| * access the stream to which the stdout from cvs should go | |||||
| * if this stream has already been set, it will be returned | |||||
| * if the stream has not yet been set, if the attribute output | |||||
| * has been set, the output stream will go to the output file | |||||
| * otherwise the output will go to ant's logging system | |||||
| * @return output stream to which cvs'stdout should go to | |||||
| */ | |||||
| protected OutputStream getOutputStream() { | protected OutputStream getOutputStream() { | ||||
| if (this.outputStream == null) { | if (this.outputStream == null) { | ||||
| @@ -224,11 +244,23 @@ public abstract class AbstractCvsTask extends Task { | |||||
| return this.outputStream; | return this.outputStream; | ||||
| } | } | ||||
| /** | |||||
| * sets a stream to which the stderr from the cvs exe should go | |||||
| * @param errorStream an output stream willing to process stderr | |||||
| */ | |||||
| protected void setErrorStream(OutputStream errorStream) { | protected void setErrorStream(OutputStream errorStream) { | ||||
| this.errorStream = errorStream; | this.errorStream = errorStream; | ||||
| } | } | ||||
| /** | |||||
| * access the stream to which the stderr from cvs should go | |||||
| * if this stream has already been set, it will be returned | |||||
| * if the stream has not yet been set, if the attribute error | |||||
| * has been set, the output stream will go to the file denoted by the error attribute | |||||
| * otherwise the stderr output will go to ant's logging system | |||||
| * @return output stream to which cvs'stderr should go to | |||||
| */ | |||||
| protected OutputStream getErrorStream() { | protected OutputStream getErrorStream() { | ||||
| if (this.errorStream == null) { | if (this.errorStream == null) { | ||||
| @@ -253,7 +285,8 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * Sets up the environment for toExecute and then runs it. | * Sets up the environment for toExecute and then runs it. | ||||
| * @throws BuildException | |||||
| * @param toExecute the command line to execute | |||||
| * @throws BuildException if failonError is set to true and the cvs command fails | |||||
| */ | */ | ||||
| protected void runCommand(Commandline toExecute) throws BuildException { | protected void runCommand(Commandline toExecute) throws BuildException { | ||||
| // XXX: we should use JCVS (www.ice.com/JCVS) instead of | // XXX: we should use JCVS (www.ice.com/JCVS) instead of | ||||
| @@ -386,13 +419,17 @@ public abstract class AbstractCvsTask extends Task { | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * do the work | |||||
| * @throws BuildException if failonerror is set to true and the cvs command fails. | |||||
| */ | |||||
| public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
| String savedCommand = getCommand(); | String savedCommand = getCommand(); | ||||
| if (this.getCommand() == null && vecCommandlines.size() == 0) { | if (this.getCommand() == null && vecCommandlines.size() == 0) { | ||||
| // re-implement legacy behaviour: | // re-implement legacy behaviour: | ||||
| this.setCommand(AbstractCvsTask.default_command); | |||||
| this.setCommand(AbstractCvsTask.DEFAULT_COMMAND); | |||||
| } | } | ||||
| String c = this.getCommand(); | String c = this.getCommand(); | ||||
| @@ -442,7 +479,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * The CVSROOT variable. | * The CVSROOT variable. | ||||
| * | * | ||||
| * @param root | |||||
| * @param root the CVSROOT variable | |||||
| */ | */ | ||||
| public void setCvsRoot(String root) { | public void setCvsRoot(String root) { | ||||
| @@ -456,6 +493,10 @@ public abstract class AbstractCvsTask extends Task { | |||||
| this.cvsRoot = root; | this.cvsRoot = root; | ||||
| } | } | ||||
| /** | |||||
| * access the the CVSROOT variable | |||||
| * @return CVSROOT | |||||
| */ | |||||
| public String getCvsRoot() { | public String getCvsRoot() { | ||||
| return this.cvsRoot; | return this.cvsRoot; | ||||
| @@ -464,7 +505,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * The CVS_RSH variable. | * The CVS_RSH variable. | ||||
| * | * | ||||
| * @param rsh | |||||
| * @param rsh the CVS_RSH variable | |||||
| */ | */ | ||||
| public void setCvsRsh(String rsh) { | public void setCvsRsh(String rsh) { | ||||
| // Check if not real cvsrsh => set it to null | // Check if not real cvsrsh => set it to null | ||||
| @@ -477,6 +518,10 @@ public abstract class AbstractCvsTask extends Task { | |||||
| this.cvsRsh = rsh; | this.cvsRsh = rsh; | ||||
| } | } | ||||
| /** | |||||
| * access the CVS_RSH variable | |||||
| * @return the CVS_RSH variable | |||||
| */ | |||||
| public String getCvsRsh() { | public String getCvsRsh() { | ||||
| return this.cvsRsh; | return this.cvsRsh; | ||||
| @@ -485,12 +530,16 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * Port used by CVS to communicate with the server. | * Port used by CVS to communicate with the server. | ||||
| * | * | ||||
| * @param port | |||||
| * @param port port of CVS | |||||
| */ | */ | ||||
| public void setPort(int port) { | public void setPort(int port) { | ||||
| this.port = port; | this.port = port; | ||||
| } | } | ||||
| /** | |||||
| * access the port of CVS | |||||
| * @return the port of CVS | |||||
| */ | |||||
| public int getPort() { | public int getPort() { | ||||
| return this.port; | return this.port; | ||||
| @@ -499,12 +548,16 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * Password file to read passwords from. | * Password file to read passwords from. | ||||
| * | * | ||||
| * @param passFile | |||||
| * @param passFile password file to read passwords from | |||||
| */ | */ | ||||
| public void setPassfile(File passFile) { | public void setPassfile(File passFile) { | ||||
| this.passFile = passFile; | this.passFile = passFile; | ||||
| } | } | ||||
| /** | |||||
| * find the password file | |||||
| * @return password file | |||||
| */ | |||||
| public File getPassFile() { | public File getPassFile() { | ||||
| return this.passFile; | return this.passFile; | ||||
| @@ -513,12 +566,17 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * The directory where the checked out files should be placed. | * The directory where the checked out files should be placed. | ||||
| * | * | ||||
| * @param dest | |||||
| * @param dest directory where the checked out files should be placed | |||||
| */ | */ | ||||
| public void setDest(File dest) { | public void setDest(File dest) { | ||||
| this.dest = dest; | this.dest = dest; | ||||
| } | } | ||||
| /** | |||||
| * get the file where the checked out files should be placed | |||||
| * | |||||
| * @return directory where the checked out files should be placed | |||||
| */ | |||||
| public File getDest() { | public File getDest() { | ||||
| return this.dest; | return this.dest; | ||||
| @@ -527,12 +585,17 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * The package/module to operate upon. | * The package/module to operate upon. | ||||
| * | * | ||||
| * @param p | |||||
| * @param p package or module to operate upon | |||||
| */ | */ | ||||
| public void setPackage(String p) { | public void setPackage(String p) { | ||||
| this.cvsPackage = p; | this.cvsPackage = p; | ||||
| } | } | ||||
| /** | |||||
| * access the package or module to operate upon | |||||
| * | |||||
| * @return package/module | |||||
| */ | |||||
| public String getPackage() { | public String getPackage() { | ||||
| return this.cvsPackage; | return this.cvsPackage; | ||||
| @@ -540,7 +603,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * The tag of the package/module to operate upon. | * The tag of the package/module to operate upon. | ||||
| * @param p | |||||
| * @param p tag | |||||
| */ | */ | ||||
| public void setTag(String p) { | public void setTag(String p) { | ||||
| // Check if not real tag => set it to null | // Check if not real tag => set it to null | ||||
| @@ -553,11 +616,22 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * This needs to be public to allow configuration | * This needs to be public to allow configuration | ||||
| * of commands externally. | * of commands externally. | ||||
| * @param arg command argument | |||||
| */ | */ | ||||
| public void addCommandArgument(String arg) { | public void addCommandArgument(String arg) { | ||||
| this.addCommandArgument(cmd, arg); | this.addCommandArgument(cmd, arg); | ||||
| } | } | ||||
| /** | |||||
| * add a command line argument to an external command | |||||
| * | |||||
| * I do not understand what this method does in this class ??? | |||||
| * particulary not why it is public ???? | |||||
| * AntoineLL July 23d 2003 | |||||
| * | |||||
| * @param c command line to which one argument should be added | |||||
| * @param arg argument to add | |||||
| */ | |||||
| public void addCommandArgument(Commandline c, String arg) { | public void addCommandArgument(Commandline c, String arg) { | ||||
| c.createArgument().setValue(arg); | c.createArgument().setValue(arg); | ||||
| } | } | ||||
| @@ -565,7 +639,8 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * Use the most recent revision no later than the given date. | * Use the most recent revision no later than the given date. | ||||
| * @param p | |||||
| * @param p a date as string in a format that the CVS executable can understand | |||||
| * see man cvs | |||||
| */ | */ | ||||
| public void setDate(String p) { | public void setDate(String p) { | ||||
| if (p != null && p.trim().length() > 0) { | if (p != null && p.trim().length() > 0) { | ||||
| @@ -576,18 +651,30 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * The CVS command to execute. | * The CVS command to execute. | ||||
| * @param c | |||||
| * | |||||
| * This should be deprecated, it is better to use the Commandline class ? | |||||
| * AntoineLL July 23d 2003 | |||||
| * | |||||
| * @param c a command as string | |||||
| */ | */ | ||||
| public void setCommand(String c) { | public void setCommand(String c) { | ||||
| this.command = c; | this.command = c; | ||||
| } | } | ||||
| /** | |||||
| * accessor to a command line as string | |||||
| * | |||||
| * This should be deprecated | |||||
| * AntoineLL July 23d 2003 | |||||
| * | |||||
| * @return command line as string | |||||
| */ | |||||
| public String getCommand() { | public String getCommand() { | ||||
| return this.command; | return this.command; | ||||
| } | } | ||||
| /** | /** | ||||
| * If true, suppress informational messages. | * If true, suppress informational messages. | ||||
| * @param q | |||||
| * @param q if true, suppress informational messages | |||||
| */ | */ | ||||
| public void setQuiet(boolean q) { | public void setQuiet(boolean q) { | ||||
| quiet = q; | quiet = q; | ||||
| @@ -596,7 +683,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * If true, report only and don't change any files. | * If true, report only and don't change any files. | ||||
| * | * | ||||
| * @param ne | |||||
| * @param ne if true, report only and do not change any files. | |||||
| */ | */ | ||||
| public void setNoexec(boolean ne) { | public void setNoexec(boolean ne) { | ||||
| noexec = ne; | noexec = ne; | ||||
| @@ -604,7 +691,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * The file to direct standard output from the command. | * The file to direct standard output from the command. | ||||
| * @param output | |||||
| * @param output a file to which stdout should go | |||||
| */ | */ | ||||
| public void setOutput(File output) { | public void setOutput(File output) { | ||||
| this.output = output; | this.output = output; | ||||
| @@ -613,7 +700,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * The file to direct standard error from the command. | * The file to direct standard error from the command. | ||||
| * | * | ||||
| * @param error | |||||
| * @param error a file to which stderr should go | |||||
| */ | */ | ||||
| public void setError(File error) { | public void setError(File error) { | ||||
| this.error = error; | this.error = error; | ||||
| @@ -621,7 +708,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * Whether to append output/error when redirecting to a file. | * Whether to append output/error when redirecting to a file. | ||||
| * @param value | |||||
| * @param value true indicated you want to append | |||||
| */ | */ | ||||
| public void setAppend(boolean value) { | public void setAppend(boolean value) { | ||||
| this.append = value; | this.append = value; | ||||
| @@ -631,7 +718,8 @@ public abstract class AbstractCvsTask extends Task { | |||||
| * Stop the build process if the command exits with | * Stop the build process if the command exits with | ||||
| * a return code other than 0. | * a return code other than 0. | ||||
| * Defaults to false. | * Defaults to false. | ||||
| * @param failOnError | |||||
| * @param failOnError stop the build process if the command exits with | |||||
| * a return code other than 0 | |||||
| */ | */ | ||||
| public void setFailOnError(boolean failOnError) { | public void setFailOnError(boolean failOnError) { | ||||
| this.failOnError = failOnError; | this.failOnError = failOnError; | ||||
| @@ -639,6 +727,22 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * Configure a commandline element for things like cvsRoot, quiet, etc. | * Configure a commandline element for things like cvsRoot, quiet, etc. | ||||
| * @param c the command line which will be configured | |||||
| * if the commandline is initially null, the function is a noop | |||||
| * otherwise the function append to the commandline arguments concerning | |||||
| * <ul> | |||||
| * <li> | |||||
| * cvs package | |||||
| * </li> | |||||
| * <li> | |||||
| * compression | |||||
| * </li> | |||||
| * <li> | |||||
| * quiet | |||||
| * </li> | |||||
| * <li>cvsroot</li> | |||||
| * <li>noexec</li> | |||||
| * </ul> | |||||
| */ | */ | ||||
| protected void configureCommandline(Commandline c) { | protected void configureCommandline(Commandline c) { | ||||
| if (c == null) { | if (c == null) { | ||||
| @@ -648,7 +752,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| if (cvsPackage != null) { | if (cvsPackage != null) { | ||||
| c.createArgument().setLine(cvsPackage); | c.createArgument().setLine(cvsPackage); | ||||
| } | } | ||||
| if (this.compression > 0 && this.compression < 10) { | |||||
| if (this.compression > 0 && this.compression <= MAXIMUM_COMRESSION_LEVEL) { | |||||
| c.createArgument(true).setValue("-z" + this.compression); | c.createArgument(true).setValue("-z" + this.compression); | ||||
| } | } | ||||
| if (quiet) { | if (quiet) { | ||||
| @@ -662,21 +766,27 @@ public abstract class AbstractCvsTask extends Task { | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * remove a particular command from a vector of command lines | |||||
| * @param c command line which should be removed | |||||
| */ | |||||
| protected void removeCommandline(Commandline c) { | protected void removeCommandline(Commandline c) { | ||||
| vecCommandlines.removeElement(c); | vecCommandlines.removeElement(c); | ||||
| } | } | ||||
| /** | /** | ||||
| * Adds direct command-line to execute. | * Adds direct command-line to execute. | ||||
| * @param c | |||||
| * @param c command line to execute | |||||
| */ | */ | ||||
| public void addConfiguredCommandline(Commandline c) { | public void addConfiguredCommandline(Commandline c) { | ||||
| this.addConfiguredCommandline(c, false); | this.addConfiguredCommandline(c, false); | ||||
| } | } | ||||
| /** | /** | ||||
| * Configures and adds the given Commandline. | |||||
| * @param insertAtStart If true, c is | |||||
| * Configures and adds the given Commandline. | |||||
| * @param c commandline to insert | |||||
| * @param insertAtStart If true, c is | |||||
| * inserted at the beginning of the vector of command lines | |||||
| */ | */ | ||||
| public void addConfiguredCommandline(Commandline c, | public void addConfiguredCommandline(Commandline c, | ||||
| boolean insertAtStart) { | boolean insertAtStart) { | ||||
| @@ -694,6 +804,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| /** | /** | ||||
| * If set to a value 1-9 it adds -zN to the cvs command line, else | * If set to a value 1-9 it adds -zN to the cvs command line, else | ||||
| * it disables compression. | * it disables compression. | ||||
| * @param level compression level 1 to 9 | |||||
| */ | */ | ||||
| public void setCompressionLevel(int level) { | public void setCompressionLevel(int level) { | ||||
| this.compression = level; | this.compression = level; | ||||
| @@ -136,6 +136,7 @@ public class Ant extends Task { | |||||
| /** | /** | ||||
| * If true, pass all properties to the new Ant project. | * If true, pass all properties to the new Ant project. | ||||
| * Defaults to true. | * Defaults to true. | ||||
| * @param value if true pass all properties to the new Ant project. | |||||
| */ | */ | ||||
| public void setInheritAll(boolean value) { | public void setInheritAll(boolean value) { | ||||
| inheritAll = value; | inheritAll = value; | ||||
| @@ -144,6 +145,7 @@ public class Ant extends Task { | |||||
| /** | /** | ||||
| * If true, pass all references to the new Ant project. | * If true, pass all references to the new Ant project. | ||||
| * Defaults to false. | * Defaults to false. | ||||
| * @param value if true, pass all references to the new Ant project | |||||
| */ | */ | ||||
| public void setInheritRefs(boolean value) { | public void setInheritRefs(boolean value) { | ||||
| inheritRefs = value; | inheritRefs = value; | ||||
| @@ -261,6 +263,7 @@ public class Ant extends Task { | |||||
| /** | /** | ||||
| * Pass output sent to System.out to the new project. | * Pass output sent to System.out to the new project. | ||||
| * | * | ||||
| * @param output a line of output | |||||
| * @since Ant 1.5 | * @since Ant 1.5 | ||||
| */ | */ | ||||
| public void handleOutput(String output) { | public void handleOutput(String output) { | ||||
| @@ -272,6 +275,16 @@ public class Ant extends Task { | |||||
| } | } | ||||
| /** | /** | ||||
| * Process input into the ant task | |||||
| * | |||||
| * @param buffer the buffer into which data is to be read. | |||||
| * @param offset the offset into the buffer at which data is stored. | |||||
| * @param length the amount of data to read | |||||
| * | |||||
| * @return the number of bytes read | |||||
| * | |||||
| * @exception IOException if the data cannot be read | |||||
| * | |||||
| * @see Task#handleInput(byte[], int, int) | * @see Task#handleInput(byte[], int, int) | ||||
| * | * | ||||
| * @since Ant 1.6 | * @since Ant 1.6 | ||||
| @@ -288,6 +301,8 @@ public class Ant extends Task { | |||||
| /** | /** | ||||
| * Pass output sent to System.out to the new project. | * Pass output sent to System.out to the new project. | ||||
| * | * | ||||
| * @param output The output to log. Should not be <code>null</code>. | |||||
| * | |||||
| * @since Ant 1.5.2 | * @since Ant 1.5.2 | ||||
| */ | */ | ||||
| public void handleFlush(String output) { | public void handleFlush(String output) { | ||||
| @@ -301,6 +316,8 @@ public class Ant extends Task { | |||||
| /** | /** | ||||
| * Pass output sent to System.err to the new project. | * Pass output sent to System.err to the new project. | ||||
| * | * | ||||
| * @param output The error output to log. Should not be <code>null</code>. | |||||
| * | |||||
| * @since Ant 1.5 | * @since Ant 1.5 | ||||
| */ | */ | ||||
| public void handleErrorOutput(String output) { | public void handleErrorOutput(String output) { | ||||
| @@ -314,6 +331,8 @@ public class Ant extends Task { | |||||
| /** | /** | ||||
| * Pass output sent to System.err to the new project. | * Pass output sent to System.err to the new project. | ||||
| * | * | ||||
| * @param output The error output to log. Should not be <code>null</code>. | |||||
| * | |||||
| * @since Ant 1.5.2 | * @since Ant 1.5.2 | ||||
| */ | */ | ||||
| public void handleErrorFlush(String output) { | public void handleErrorFlush(String output) { | ||||
| @@ -326,6 +345,8 @@ public class Ant extends Task { | |||||
| /** | /** | ||||
| * Do the execution. | * Do the execution. | ||||
| * @throws BuildException if a target tries to call itself | |||||
| * probably also if a BuildException is thrown by the new project | |||||
| */ | */ | ||||
| public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
| File savedDir = dir; | File savedDir = dir; | ||||
| @@ -414,6 +435,7 @@ public class Ant extends Task { | |||||
| /** | /** | ||||
| * Override the properties in the new project with the one | * Override the properties in the new project with the one | ||||
| * explicitly defined as nested elements here. | * explicitly defined as nested elements here. | ||||
| * @throws BuildException under unknown circumstances | |||||
| */ | */ | ||||
| private void overrideProperties() throws BuildException { | private void overrideProperties() throws BuildException { | ||||
| Enumeration e = properties.elements(); | Enumeration e = properties.elements(); | ||||
| @@ -430,6 +452,7 @@ public class Ant extends Task { | |||||
| * new project. Also copy over all references that don't override | * new project. Also copy over all references that don't override | ||||
| * existing references in the new project if inheritrefs has been | * existing references in the new project if inheritrefs has been | ||||
| * requested. | * requested. | ||||
| * @throws BuildException if a reference does not have a refid | |||||
| */ | */ | ||||
| private void addReferences() throws BuildException { | private void addReferences() throws BuildException { | ||||
| Hashtable thisReferences | Hashtable thisReferences | ||||
| @@ -528,7 +551,7 @@ public class Ant extends Task { | |||||
| * Copies all properties from the given table to the new project - | * Copies all properties from the given table to the new project - | ||||
| * ommiting those that have already been set in the new project as | * ommiting those that have already been set in the new project as | ||||
| * well as properties named basedir or ant.file. | * well as properties named basedir or ant.file. | ||||
| * | |||||
| * @param props properties to copy to the new project | |||||
| * @since Ant 1.6 | * @since Ant 1.6 | ||||
| */ | */ | ||||
| private void addAlmostAll(Hashtable props) { | private void addAlmostAll(Hashtable props) { | ||||
| @@ -554,6 +577,7 @@ public class Ant extends Task { | |||||
| * Defaults to the current project's basedir, unless inheritall | * Defaults to the current project's basedir, unless inheritall | ||||
| * has been set to false, in which case it doesn't have a default | * has been set to false, in which case it doesn't have a default | ||||
| * value. This will override the basedir setting of the called project. | * value. This will override the basedir setting of the called project. | ||||
| * @param d new directory | |||||
| */ | */ | ||||
| public void setDir(File d) { | public void setDir(File d) { | ||||
| this.dir = d; | this.dir = d; | ||||
| @@ -563,6 +587,7 @@ public class Ant extends Task { | |||||
| * The build file to use. | * The build file to use. | ||||
| * Defaults to "build.xml". This file is expected to be a filename relative | * Defaults to "build.xml". This file is expected to be a filename relative | ||||
| * to the dir attribute given. | * to the dir attribute given. | ||||
| * @param s build file to use | |||||
| */ | */ | ||||
| public void setAntfile(String s) { | public void setAntfile(String s) { | ||||
| // @note: it is a string and not a file to handle relative/absolute | // @note: it is a string and not a file to handle relative/absolute | ||||
| @@ -574,6 +599,7 @@ public class Ant extends Task { | |||||
| /** | /** | ||||
| * The target of the new Ant project to execute. | * The target of the new Ant project to execute. | ||||
| * Defaults to the new project's default target. | * Defaults to the new project's default target. | ||||
| * @param s target to invoke | |||||
| */ | */ | ||||
| public void setTarget(String s) { | public void setTarget(String s) { | ||||
| if (s.equals("")) { | if (s.equals("")) { | ||||
| @@ -588,6 +614,7 @@ public class Ant extends Task { | |||||
| * This is relative to the value of the dir attribute | * This is relative to the value of the dir attribute | ||||
| * if it has been set or to the base directory of the | * if it has been set or to the base directory of the | ||||
| * current project otherwise. | * current project otherwise. | ||||
| * @param s file to which the output should go to | |||||
| */ | */ | ||||
| public void setOutput(String s) { | public void setOutput(String s) { | ||||
| this.output = s; | this.output = s; | ||||
| @@ -596,6 +623,7 @@ public class Ant extends Task { | |||||
| /** | /** | ||||
| * Property to pass to the new project. | * Property to pass to the new project. | ||||
| * The property is passed as a 'user property' | * The property is passed as a 'user property' | ||||
| * @return new property created | |||||
| */ | */ | ||||
| public Property createProperty() { | public Property createProperty() { | ||||
| if (newProject == null) { | if (newProject == null) { | ||||
| @@ -611,6 +639,7 @@ public class Ant extends Task { | |||||
| /** | /** | ||||
| * Reference element identifying a data type to carry | * Reference element identifying a data type to carry | ||||
| * over to the new project. | * over to the new project. | ||||
| * @param r reference to add | |||||
| */ | */ | ||||
| public void addReference(Reference r) { | public void addReference(Reference r) { | ||||
| references.addElement(r); | references.addElement(r); | ||||
| @@ -619,6 +648,7 @@ public class Ant extends Task { | |||||
| /** | /** | ||||
| * Set of properties to pass to the new project. | * Set of properties to pass to the new project. | ||||
| * | * | ||||
| * @param ps property set to add | |||||
| * @since Ant 1.6 | * @since Ant 1.6 | ||||
| */ | */ | ||||
| public void addPropertyset(PropertySet ps) { | public void addPropertyset(PropertySet ps) { | ||||
| @@ -96,6 +96,7 @@ public class AntStructure extends Task { | |||||
| /** | /** | ||||
| * The output file. | * The output file. | ||||
| * @param output the output file | |||||
| */ | */ | ||||
| public void setOutput(File output) { | public void setOutput(File output) { | ||||
| this.output = output; | this.output = output; | ||||
| @@ -358,6 +359,8 @@ public class AntStructure extends Task { | |||||
| /** | /** | ||||
| * Does this String match the XML-NMTOKEN production? | * Does this String match the XML-NMTOKEN production? | ||||
| * @param s the string to test | |||||
| * @return true if the string matche the XML-NMTOKEN | |||||
| */ | */ | ||||
| protected boolean isNmtoken(String s) { | protected boolean isNmtoken(String s) { | ||||
| final int length = s.length(); | final int length = s.length(); | ||||
| @@ -377,6 +380,8 @@ public class AntStructure extends Task { | |||||
| * | * | ||||
| * <p>Otherwise they are not suitable as an enumerated attribute, | * <p>Otherwise they are not suitable as an enumerated attribute, | ||||
| * for example.</p> | * for example.</p> | ||||
| * @param s the array of string to test | |||||
| * @return true if all the strings in the array math XML-NMTOKEN | |||||
| */ | */ | ||||
| protected boolean areNmtokens(String[] s) { | protected boolean areNmtokens(String[] s) { | ||||
| for (int i = 0; i < s.length; i++) { | for (int i = 0; i < s.length; i++) { | ||||
| @@ -202,6 +202,7 @@ public class Available extends Task implements Condition { | |||||
| * setType(Available.FileDir) to make Ant's Introspection | * setType(Available.FileDir) to make Ant's Introspection | ||||
| * mechanism do the work and also to encapsulate operations on | * mechanism do the work and also to encapsulate operations on | ||||
| * the type in its own class. | * the type in its own class. | ||||
| * @param type the type of resource | |||||
| */ | */ | ||||
| public void setType(String type) { | public void setType(String type) { | ||||
| log("DEPRECATED - The setType(String) method has been deprecated." | log("DEPRECATED - The setType(String) method has been deprecated." | ||||
| @@ -510,13 +511,13 @@ public class Available extends Task implements Condition { | |||||
| */ | */ | ||||
| public static class FileDir extends EnumeratedAttribute { | public static class FileDir extends EnumeratedAttribute { | ||||
| private static final String[] values = {"file", "dir"}; | |||||
| private static final String[] VALUES = {"file", "dir"}; | |||||
| /** | /** | ||||
| * @see EnumeratedAttribute#getValues | * @see EnumeratedAttribute#getValues | ||||
| */ | */ | ||||
| public String[] getValues() { | public String[] getValues() { | ||||
| return values; | |||||
| return VALUES; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -95,14 +95,16 @@ public class Basename extends Task { | |||||
| private String suffix; | private String suffix; | ||||
| /** | /** | ||||
| * File or directory to get base name from. | |||||
| */ | |||||
| * file or directory to get base name from | |||||
| * @param file file or directory to get base name from | |||||
| */ | |||||
| public void setFile(File file) { | public void setFile(File file) { | ||||
| this.file = file; | this.file = file; | ||||
| } | } | ||||
| /** | /** | ||||
| * Property to set base name to. | * Property to set base name to. | ||||
| * @param property name of property | |||||
| */ | */ | ||||
| public void setProperty(String property) { | public void setProperty(String property) { | ||||
| this.property = property; | this.property = property; | ||||
| @@ -110,13 +112,17 @@ public class Basename extends Task { | |||||
| /** | /** | ||||
| * Optional suffix to remove from base name. | * Optional suffix to remove from base name. | ||||
| * @param suffix suffix to remove from base name | |||||
| */ | */ | ||||
| public void setSuffix(String suffix) { | public void setSuffix(String suffix) { | ||||
| this.suffix = suffix; | this.suffix = suffix; | ||||
| } | } | ||||
| // The method executing the task | |||||
| /** | |||||
| * do the work | |||||
| * @throws BuildException if required attributes are not supplied | |||||
| * property and attribute are required attributes | |||||
| */ | |||||
| public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
| if (property == null) { | if (property == null) { | ||||
| throw new BuildException("property attribute required", getLocation()); | throw new BuildException("property attribute required", getLocation()); | ||||
| @@ -1,7 +1,7 @@ | |||||
| /* | /* | ||||
| * The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
| * | * | ||||
| * Copyright (c) 2002 The Apache Software Foundation. All rights | |||||
| * Copyright (c) 2002-2003 The Apache Software Foundation. All rights | |||||
| * reserved. | * reserved. | ||||
| * | * | ||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| @@ -60,6 +60,7 @@ import java.io.IOException; | |||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
| import org.apache.tools.ant.Project; | |||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| /** | /** | ||||
| @@ -86,7 +87,7 @@ public class BuildNumber | |||||
| private static final String DEFAULT_FILENAME = DEFAULT_PROPERTY_NAME; | private static final String DEFAULT_FILENAME = DEFAULT_PROPERTY_NAME; | ||||
| /** The File in which the build number is stored. */ | /** The File in which the build number is stored. */ | ||||
| private File m_file; | |||||
| private File myFile; | |||||
| /** | /** | ||||
| @@ -96,7 +97,7 @@ public class BuildNumber | |||||
| * @param file the file in which build number is stored. | * @param file the file in which build number is stored. | ||||
| */ | */ | ||||
| public void setFile(final File file) { | public void setFile(final File file) { | ||||
| m_file = file; | |||||
| myFile = file; | |||||
| } | } | ||||
| @@ -107,7 +108,7 @@ public class BuildNumber | |||||
| */ | */ | ||||
| public void execute() | public void execute() | ||||
| throws BuildException { | throws BuildException { | ||||
| File savedFile = m_file; // may be altered in validate | |||||
| File savedFile = myFile; // may be altered in validate | |||||
| validate(); | validate(); | ||||
| @@ -121,13 +122,13 @@ public class BuildNumber | |||||
| FileOutputStream output = null; | FileOutputStream output = null; | ||||
| try { | try { | ||||
| output = new FileOutputStream(m_file); | |||||
| output = new FileOutputStream(myFile); | |||||
| final String header = "Build Number for ANT. Do not edit!"; | final String header = "Build Number for ANT. Do not edit!"; | ||||
| properties.save(output, header); | properties.save(output, header); | ||||
| } catch (final IOException ioe) { | } catch (final IOException ioe) { | ||||
| final String message = "Error while writing " + m_file; | |||||
| final String message = "Error while writing " + myFile; | |||||
| throw new BuildException(message, ioe); | throw new BuildException(message, ioe); | ||||
| } finally { | } finally { | ||||
| @@ -135,9 +136,10 @@ public class BuildNumber | |||||
| try { | try { | ||||
| output.close(); | output.close(); | ||||
| } catch (final IOException ioe) { | } catch (final IOException ioe) { | ||||
| getProject().log("error closing output stream " + ioe, Project.MSG_ERR); | |||||
| } | } | ||||
| } | } | ||||
| m_file = savedFile; | |||||
| myFile = savedFile; | |||||
| } | } | ||||
| //Finally set the property | //Finally set the property | ||||
| @@ -163,7 +165,7 @@ public class BuildNumber | |||||
| return Integer.parseInt(buildNumber); | return Integer.parseInt(buildNumber); | ||||
| } catch (final NumberFormatException nfe) { | } catch (final NumberFormatException nfe) { | ||||
| final String message = | final String message = | ||||
| m_file + " contains a non integer build number: " + buildNumber; | |||||
| myFile + " contains a non integer build number: " + buildNumber; | |||||
| throw new BuildException(message, nfe); | throw new BuildException(message, nfe); | ||||
| } | } | ||||
| @@ -183,7 +185,7 @@ public class BuildNumber | |||||
| try { | try { | ||||
| final Properties properties = new Properties(); | final Properties properties = new Properties(); | ||||
| input = new FileInputStream(m_file); | |||||
| input = new FileInputStream(myFile); | |||||
| properties.load(input); | properties.load(input); | ||||
| return properties; | return properties; | ||||
| } catch (final IOException ioe) { | } catch (final IOException ioe) { | ||||
| @@ -193,6 +195,7 @@ public class BuildNumber | |||||
| try { | try { | ||||
| input.close(); | input.close(); | ||||
| } catch (final IOException ioe) { | } catch (final IOException ioe) { | ||||
| getProject().log("error closing input stream " + ioe, Project.MSG_ERR); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -206,29 +209,29 @@ public class BuildNumber | |||||
| */ | */ | ||||
| private void validate() | private void validate() | ||||
| throws BuildException { | throws BuildException { | ||||
| if (null == m_file) { | |||||
| m_file = getProject().resolveFile(DEFAULT_FILENAME); | |||||
| if (null == myFile) { | |||||
| myFile = getProject().resolveFile(DEFAULT_FILENAME); | |||||
| } | } | ||||
| if (!m_file.exists()) { | |||||
| if (!myFile.exists()) { | |||||
| try { | try { | ||||
| FileUtils.newFileUtils().createNewFile(m_file); | |||||
| FileUtils.newFileUtils().createNewFile(myFile); | |||||
| } catch (final IOException ioe) { | } catch (final IOException ioe) { | ||||
| final String message = | final String message = | ||||
| m_file + " doesn't exist and new file can't be created."; | |||||
| myFile + " doesn't exist and new file can't be created."; | |||||
| throw new BuildException(message, ioe); | throw new BuildException(message, ioe); | ||||
| } | } | ||||
| } | } | ||||
| if (!m_file.canRead()) { | |||||
| final String message = "Unable to read from " + m_file + "."; | |||||
| if (!myFile.canRead()) { | |||||
| final String message = "Unable to read from " + myFile + "."; | |||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| } | } | ||||
| if (!m_file.canWrite()) { | |||||
| final String message = "Unable to write to " + m_file + "."; | |||||
| if (!myFile.canWrite()) { | |||||
| final String message = "Unable to write to " + myFile + "."; | |||||
| throw new BuildException(message); | throw new BuildException(message); | ||||
| } | } | ||||