diff --git a/WHATSNEW b/WHATSNEW index 45bcf8c02..eb5aa544e 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -9,8 +9,9 @@ Changes that could break older environments: would only do so if under special circumstances. Ant 1.8.2 now consistently won't replace a read-only file by default. The same is true for a number of other tasks. - The and task now have a new force attribute that can - be used to make the task overwrite read-only destinations. + The , and tasks now have a new force attribute + and has a new forceReadonly attribute that can be used to + make the task overwrite read-only destinations. Bugzilla Report 49261. Fixed bugs: @@ -19,6 +20,10 @@ Fixed bugs: Other changes: -------------- + * 's force attribute has been deprecated in favor of a new + overwrite attribute that is consistent with 's attribute + names. + Changes from Ant 1.8.0 TO Ant 1.8.1 =================================== diff --git a/docs/manual/CoreTasks/concat.html b/docs/manual/CoreTasks/concat.html index a2c5646fd..ddc9549ee 100644 --- a/docs/manual/CoreTasks/concat.html +++ b/docs/manual/CoreTasks/concat.html @@ -83,12 +83,29 @@ Resource Collections are used to Specifies whether or not the file specified by 'destfile' should be written to even if it is newer than all source files. - since Ant 1.6. + deprecated, use the overwrite attribute instead + Defaults to "yes". + + No + + + overwrite + + Specifies whether or not the file specified by 'destfile' + should be written to even if it is newer than all source files. + since Ant 1.8.2. Defaults to "yes". No + + forceReadOnly + Overwrite read-only destination + files. since Ant 1.8.2 + No; defaults to false. + + encoding diff --git a/docs/manual/CoreTasks/echo.html b/docs/manual/CoreTasks/echo.html index 833368f56..377ab7578 100644 --- a/docs/manual/CoreTasks/echo.html +++ b/docs/manual/CoreTasks/echo.html @@ -79,6 +79,12 @@ ignored

encoding to use, default is ""; the local system encoding. since Ant 1.7 No + + force + Overwrite read-only destination + files. since Ant 1.8.2 + No; defaults to false. +

Examples

diff --git a/src/etc/testcases/taskdefs/concat.xml b/src/etc/testcases/taskdefs/concat.xml index 8e6112679..602707013 100644 --- a/src/etc/testcases/taskdefs/concat.xml +++ b/src/etc/testcases/taskdefs/concat.xml @@ -110,7 +110,7 @@ - + diff --git a/src/main/org/apache/tools/ant/taskdefs/Concat.java b/src/main/org/apache/tools/ant/taskdefs/Concat.java index 9a8c433bf..0cee4913f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Concat.java +++ b/src/main/org/apache/tools/ant/taskdefs/Concat.java @@ -471,6 +471,8 @@ public class Concat extends Task implements ResourceCollection { private Vector filterChains; /** ignore dates on input files */ private boolean forceOverwrite = true; + /** overwrite read-only files */ + private boolean force = false; /** String to place at the start of the concatented stream */ private TextElement footer; /** String to place at the end of the concatented stream */ @@ -526,6 +528,7 @@ public class Concat extends Task implements ResourceCollection { eolString = StringUtils.LINE_SEP; rc = null; ignoreEmpty = true; + force = false; } // Attribute setters. @@ -581,14 +584,38 @@ public class Concat extends Task implements ResourceCollection { /** * Force overwrite existing destination file - * @param force if true always overwrite, otherwise only overwrite - * if the output file is older any of the input files. + * @param forceOverwrite if true always overwrite, otherwise only + * overwrite if the output file is older any of the + * input files. * @since Ant 1.6 + * @deprecated use #setOverwrite instead */ - public void setForce(boolean force) { + public void setForce(boolean forceOverwrite) { this.forceOverwrite = force; } + /** + * Force overwrite existing destination file + * @param forceOverwrite if true always overwrite, otherwise only + * overwrite if the output file is older any of the + * input files. + * @since Ant 1.8.2 + */ + public void setOverwrite(boolean forceOverwrite) { + setForce(forceOverwrite); + } + + /** + * Whether read-only destinations will be overwritten. + * + *

Defaults to false

+ * + * @since Ant 1.8.2 + */ + public void setForceReadOnly(boolean f) { + force = f; + } + /** * Sets the behavior when no source resource files are available. If set to * false the destination file will always be created. @@ -761,9 +788,11 @@ public class Concat extends Task implements ResourceCollection { } try { //most of these are defaulted because the concat-as-a-resource code hijacks a lot: - ResourceUtils.copyResource(new ConcatResource(c), dest == null ? new LogOutputResource( - this, Project.MSG_WARN) : dest, null, null, true, false, append, null, null, - getProject()); + ResourceUtils.copyResource(new ConcatResource(c), dest == null + ? new LogOutputResource(this, Project.MSG_WARN) + : dest, + null, null, true, false, append, null, + null, getProject(), force); } catch (IOException e) { throw new BuildException("error concatenating content to " + dest, e); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Echo.java b/src/main/org/apache/tools/ant/taskdefs/Echo.java index 0218b3e61..91b82e1da 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Echo.java +++ b/src/main/org/apache/tools/ant/taskdefs/Echo.java @@ -47,6 +47,7 @@ public class Echo extends Task { protected boolean append = false; /** encoding; set to null or empty means 'default' */ private String encoding = ""; + private boolean force = false; // by default, messages are always displayed protected int logLevel = Project.MSG_WARN; @@ -63,9 +64,12 @@ public class Echo extends Task { final String msg = "".equals(message) ? StringUtils.LINE_SEP : message; try { ResourceUtils - .copyResource(new StringResource(msg), output == null ? new LogOutputResource( - this, logLevel) : output, null, null, false, false, append, null, "" - .equals(encoding) ? null : encoding, getProject()); + .copyResource(new StringResource(msg), output == null + ? new LogOutputResource(this, logLevel) + : output, + null, null, false, false, append, null, + "".equals(encoding) ? null : encoding, + getProject(), force); } catch (IOException ioe) { throw new BuildException(ioe, getLocation()); } @@ -147,6 +151,17 @@ public class Echo extends Task { this.encoding = encoding; } + /** + * Whether read-only destinations will be overwritten. + * + *

Defaults to false

+ * + * @since Ant 1.8.2 + */ + public void setForce(boolean f) { + force = f; + } + /** * The enumerated values for the level attribute. */