diff --git a/WHATSNEW b/WHATSNEW index 43a8640d3..ee9ffbbc9 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -110,9 +110,6 @@ Fixed bugs: * and create a new parser for every file in a fileset, and so validate multiple files properly. Bugzilla Report 32791 -* New mapper, , supports scripted mapping of source files/strings to - destination strings. - Other changes: -------------- @@ -228,6 +225,11 @@ Other changes: * Added initial support for Resource Collections, including the resourcecount task. +* New mapper, , supports scripted mapping of source files/strings + to destination strings. + +* Add the echoxml task. + Changes from Ant 1.6.3 to Ant 1.6.4 =================================== diff --git a/docs/manual/CoreTasks/echoxml.html b/docs/manual/CoreTasks/echoxml.html new file mode 100755 index 000000000..94b21128e --- /dev/null +++ b/docs/manual/CoreTasks/echoxml.html @@ -0,0 +1,51 @@ + + + + + +EchoXML Task + + + + +

EchoXML

+

Description

+

Echo nested XML to the console or a file. Since Ant 1.7

+

Parameters

+ + + + + + + + + + + + + + + + +
AttributeDescriptionRequired
fileThe file to receive the XML. If omitted nested + XML will be echoed to the log.No
appendWhether to append file, if specified.No
+

Parameters specified as nested elements

+Nested XML content is required. + +

Examples

+
<echoxml file="subbuild.xml">
+  <project default="foo">
+    <target name="foo">
+      <echo>foo</echo>
+    </target>
+  </project>
+</echoxml>
+
+

Creates an Ant buildfile, subbuild.xml.

+
+

Copyright © 2005 The Apache Software Foundation. + All rights Reserved.

+ + + diff --git a/docs/manual/coretasklist.html b/docs/manual/coretasklist.html index 0893a1796..e00bf34a2 100644 --- a/docs/manual/coretasklist.html +++ b/docs/manual/coretasklist.html @@ -46,6 +46,7 @@ Dirname
Ear
Echo
+EchoXML
Exec
Fail
Filter
diff --git a/src/etc/testcases/taskdefs/echoxml.xml b/src/etc/testcases/taskdefs/echoxml.xml new file mode 100644 index 000000000..6185d4c04 --- /dev/null +++ b/src/etc/testcases/taskdefs/echoxml.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/org/apache/tools/ant/taskdefs/EchoXML.java b/src/main/org/apache/tools/ant/taskdefs/EchoXML.java new file mode 100755 index 000000000..cde7ac990 --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/EchoXML.java @@ -0,0 +1,81 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.tools.ant.taskdefs; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.io.FileOutputStream; +import java.io.FileNotFoundException; + +import org.apache.tools.ant.Project; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.util.XMLFragment; +import org.apache.tools.ant.util.DOMElementWriter; + +import org.w3c.dom.Node; +import org.w3c.dom.Element; + +/** + * Echo XML. + * @since Ant 1.7 + */ +public class EchoXML extends XMLFragment { + + private static final DOMElementWriter writer = new DOMElementWriter(); + + private File file; + private boolean append; + + /** + * Set the output file. + * @param f the output file. + */ + public void setFile(File f) { + file = f; + } + + /** + * Set whether to append the output file. + * @param b boolean append flag. + */ + public void setAppend(boolean b) { + append = b; + } + + /** + * Execute the task. + */ + public void execute() { + try { + OutputStream os = null; + if (file != null) { + os = new FileOutputStream(file, append); + } else { + os = new LogOutputStream(this, Project.MSG_INFO); + } + Node n = getFragment().getFirstChild(); + if (n == null) { + throw new BuildException("No nested XML specified"); + } + writer.write((Element) n, os); + } catch (Exception e) { + throw new BuildException(e); + } + } + +} diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties index aee966d51..91ba03c95 100644 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -208,6 +208,7 @@ apt=org.apache.tools.ant.taskdefs.Apt schemavalidate=org.apache.tools.ant.taskdefs.optional.SchemaValidate verifyjar=org.apache.tools.ant.taskdefs.VerifyJar resourcecount=org.apache.tools.ant.taskdefs.ResourceCount +echoxml=org.apache.tools.ant.taskdefs.EchoXML # deprecated ant tasks (kept for back compatibility) starteam=org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut diff --git a/src/testcases/org/apache/tools/ant/taskdefs/EchoXMLTest.java b/src/testcases/org/apache/tools/ant/taskdefs/EchoXMLTest.java new file mode 100755 index 000000000..644abaa8a --- /dev/null +++ b/src/testcases/org/apache/tools/ant/taskdefs/EchoXMLTest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs; + +import org.apache.tools.ant.BuildFileTest; + +public class EchoXMLTest extends BuildFileTest { + + public EchoXMLTest(String name) { + super(name); + } + + public void setUp() { + configureProject("src/etc/testcases/taskdefs/echoxml.xml"); + } + + public void tearDown() { + executeTarget("tearDown"); + } + + public void testPass() { + executeTarget("testPass"); + } + + public void testFail() { + expectBuildExceptionContaining("testFail", "must fail", "${foo}=bar"); + } + + public void testEmpty() { + expectBuildExceptionContaining("testEmpty", "must fail", "No nested XML specified"); + } + +}