git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278356 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -110,9 +110,6 @@ Fixed bugs: | |||||
| * <xmlvalidate> and <schemavalidate> create a new parser for every file in a | * <xmlvalidate> and <schemavalidate> create a new parser for every file in a | ||||
| fileset, and so validate multiple files properly. Bugzilla Report 32791 | fileset, and so validate multiple files properly. Bugzilla Report 32791 | ||||
| * New mapper, <scriptmapper>, supports scripted mapping of source files/strings to | |||||
| destination strings. | |||||
| Other changes: | Other changes: | ||||
| -------------- | -------------- | ||||
| @@ -228,6 +225,11 @@ Other changes: | |||||
| * Added initial support for Resource Collections, including the | * Added initial support for Resource Collections, including the | ||||
| resourcecount task. | resourcecount task. | ||||
| * New mapper, <scriptmapper>, 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 | Changes from Ant 1.6.3 to Ant 1.6.4 | ||||
| =================================== | =================================== | ||||
| @@ -0,0 +1,51 @@ | |||||
| <html> | |||||
| <head> | |||||
| <meta http-equiv="Content-Language" content="en-us"> | |||||
| <link rel="stylesheet" type="text/css" href="../stylesheets/style.css"> | |||||
| <title>EchoXML Task</title> | |||||
| </head> | |||||
| <body> | |||||
| <h2>EchoXML</h2> | |||||
| <h3>Description</h3> | |||||
| <p>Echo nested XML to the console or a file. <b>Since Ant 1.7</b></p> | |||||
| <h3>Parameters</h3> | |||||
| <table border="1" cellpadding="2" cellspacing="0"> | |||||
| <tr> | |||||
| <td valign="top"><b>Attribute</b></td> | |||||
| <td valign="top"><b>Description</b></td> | |||||
| <td align="center" valign="top"><b>Required</b></td> | |||||
| </tr> | |||||
| <tr> | |||||
| <td valign="top">file</td> | |||||
| <td valign="top">The file to receive the XML. If omitted nested | |||||
| XML will be echoed to the log.</td> | |||||
| <td valign="top" align="center">No</td> | |||||
| </tr> | |||||
| <tr> | |||||
| <td valign="top">append</td> | |||||
| <td valign="top">Whether to append <code>file</code>, if specified.</td> | |||||
| <td valign="top" align="center">No</td> | |||||
| </tr> | |||||
| </table> | |||||
| <h3>Parameters specified as nested elements</h3> | |||||
| Nested XML content is required. | |||||
| <h3>Examples</h3> | |||||
| <pre><echoxml file="subbuild.xml"> | |||||
| <project default="foo"> | |||||
| <target name="foo"> | |||||
| <echo>foo</echo> | |||||
| </target> | |||||
| </project> | |||||
| </echoxml> | |||||
| </pre> | |||||
| <p>Creates an Ant buildfile, <code>subbuild.xml</code>.</p> | |||||
| <hr> | |||||
| <p align="center">Copyright © 2005 The Apache Software Foundation. | |||||
| All rights Reserved.</p> | |||||
| </body> | |||||
| </html> | |||||
| @@ -46,6 +46,7 @@ | |||||
| <a href="CoreTasks/dirname.html">Dirname</a><br> | <a href="CoreTasks/dirname.html">Dirname</a><br> | ||||
| <a href="CoreTasks/ear.html">Ear</a><br> | <a href="CoreTasks/ear.html">Ear</a><br> | ||||
| <a href="CoreTasks/echo.html">Echo</a><br> | <a href="CoreTasks/echo.html">Echo</a><br> | ||||
| <a href="CoreTasks/echoxml.html">EchoXML</a><br> | |||||
| <a href="CoreTasks/exec.html">Exec</a><br> | <a href="CoreTasks/exec.html">Exec</a><br> | ||||
| <a href="CoreTasks/fail.html">Fail</a><br> | <a href="CoreTasks/fail.html">Fail</a><br> | ||||
| <a href="CoreTasks/filter.html">Filter</a><br> | <a href="CoreTasks/filter.html">Filter</a><br> | ||||
| @@ -0,0 +1,29 @@ | |||||
| <project> | |||||
| <property name="file" location="echoed.xml" /> | |||||
| <target name="init"> | |||||
| <echoxml file="${file}"> | |||||
| <project> | |||||
| <property name="foo" value="bar" /> | |||||
| <fail message="$$$${foo}=$${foo}"> | |||||
| <condition> | |||||
| <istrue value="${mustfail}" /> | |||||
| </condition> | |||||
| </fail> | |||||
| </project> | |||||
| </echoxml> | |||||
| </target> | |||||
| <target name="tearDown"> | |||||
| <delete file="${file}" /> | |||||
| </target> | |||||
| <target name="testPass" depends="init"> | |||||
| <ant antfile="${file}" /> | |||||
| </target> | |||||
| <target name="testFail" depends="init"> | |||||
| <ant antfile="${file}"> | |||||
| <property name="mustfail" value="true" /> | |||||
| </ant> | |||||
| </target> | |||||
| <target name="testEmpty"> | |||||
| <echoxml /> | |||||
| </target> | |||||
| </project> | |||||
| @@ -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); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -208,6 +208,7 @@ apt=org.apache.tools.ant.taskdefs.Apt | |||||
| schemavalidate=org.apache.tools.ant.taskdefs.optional.SchemaValidate | schemavalidate=org.apache.tools.ant.taskdefs.optional.SchemaValidate | ||||
| verifyjar=org.apache.tools.ant.taskdefs.VerifyJar | verifyjar=org.apache.tools.ant.taskdefs.VerifyJar | ||||
| resourcecount=org.apache.tools.ant.taskdefs.ResourceCount | resourcecount=org.apache.tools.ant.taskdefs.ResourceCount | ||||
| echoxml=org.apache.tools.ant.taskdefs.EchoXML | |||||
| # deprecated ant tasks (kept for back compatibility) | # deprecated ant tasks (kept for back compatibility) | ||||
| starteam=org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut | starteam=org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut | ||||
| @@ -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"); | |||||
| } | |||||
| } | |||||