diff --git a/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java b/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java index 2b9d412be..d41a1d5b2 100644 --- a/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java +++ b/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java @@ -115,19 +115,21 @@ public abstract class ContentTransformingResource extends ResourceDecorator { */ public Object as(Class clazz) { if (Appendable.class.isAssignableFrom(clazz)) { - final Appendable a = - (Appendable) getResource().as(Appendable.class); - if (a != null) { - return new Appendable() { - public OutputStream getAppendOutputStream() - throws IOException { - OutputStream out = a.getAppendOutputStream(); - if (out != null) { - out = wrapStream(out); + if (isAppendSupported()) { + final Appendable a = + (Appendable) getResource().as(Appendable.class); + if (a != null) { + return new Appendable() { + public OutputStream getAppendOutputStream() + throws IOException { + OutputStream out = a.getAppendOutputStream(); + if (out != null) { + out = wrapStream(out); + } + return out; } - return out; - } - }; + }; + } } return null; } @@ -136,6 +138,18 @@ public abstract class ContentTransformingResource extends ResourceDecorator { ? null : getResource().as(clazz); } + /** + * whether the transformation performed allows appends. + * + *

In general compressed outputs will become invalid if they + * are appended to, for example.

+ * + *

This implementations returns false.

+ */ + protected boolean isAppendSupported() { + return false; + } + /** * Is supposed to wrap the stream. *