Debian Codegraph @

manual/Tasks/echoproperties.html

raw
1 <!DOCTYPE html>
2 <!--
3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
9
10 https://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 -->
18 <html lang="en">
19
20 <head>
21 <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
22 <title>Echoproperties Task</title>
23 </head>
24
25 <body>
26
27 <h2 id="echoproperties">echoproperties</h2>
28 <h3>Description</h3>
29
30 <p>Displays all the current properties (or a subset of them specified by a
31 nested <code>&lt;propertyset&gt;</code>) in the project. The output can be sent to a file if
32 desired. This task can be used as a somewhat contrived means of returning data from an
33 <kbd>ant</kbd> invocation, but is really for debugging build
34 files.</p>
35
36 <h3>Parameters</h3>
37 <table class="attr">
38 <tr>
39 <th scope="col">Attribute</th>
40 <th scope="col">Description</th>
41 <th scope="col">Required</th>
42 </tr>
43 <tr>
44 <td>destfile</td>
45 <td>If specified, the value indicates the name of the file to send the output of the statement
46 to. The generated output file is compatible for loading by any Java application as a property
47 file.</td>
48 <td>No; by default, output to the log</td>
49 </tr>
50 <tr>
51 <td>prefix</td>
52 <td>a prefix which is used to filter the properties: only properties whose names start with this
53 prefix will be echoed.</td>
54 <td>No</td>
55 </tr>
56 <tr>
57 <td>regex</td>
58 <td>a regular expression which is used to filter the properties: only those properties whose
59 names match it will be echoed.</td>
60 <td>No</td>
61 </tr>
62 <tr>
63 <td>failonerror</td>
64 <td>If an error occurs while writing the properties to a file, and this attribute is enabled,
65 then a <code>BuildException</code> will be thrown, causing the build to fail. If disabled,
66 then IO errors will be reported as a log statement, and the build will continue without
67 failure from this task.</td>
68 <td>No; default is <q>true</q></td>
69 </tr>
70 <tr>
71 <td>format</td>
72 <td>One of <q>text</q> or <q>xml</q>. Determines the output format.</td>
73 <td>No; defaults to <q>text</q></td>
74 </tr>
75 </table>
76
77 <h3>Parameters specified as nested elements</h3>
78
79 <h4>propertyset</h4>
80
81 <p><em>Since Ant 1.6</em>.</p>
82
83 <p>You can specify subsets of properties to be echoed
84 with <a href="../Types/propertyset.html">propertyset</a>s. Using <code>propertyset</code>s gives
85 more control on which properties will be picked up. The attributes <var>prefix</var>
86 and <var>regex</var> are just shortcuts that use <code>propertyset</code>s internally.</p>
87
88 <h3>Examples</h3>
89 <p>Report the current properties to the log.</p>
90 <pre>&lt;echoproperties/&gt;</pre>
91
92 <p>Report the current properties to the file <samp>my.properties</samp>, and fail the build if the
93 file could not be created or written to.</p>
94 <pre>&lt;echoproperties destfile="my.properties"/&gt;</pre>
95
96 <p>Report the current properties to the file <samp>my.properties</samp>, and log a message if the
97 file could not be created or written to, but still allow the build to continue.</p>
98 <pre>&lt;echoproperties destfile="my.properties" failonerror="false"/&gt;</pre>
99
100 <p>List all properties beginning with <samp>java.</samp></p>
101 <pre>&lt;echoproperties prefix="java."/&gt;</pre>
102
103 <p>Lists all properties beginning with <samp>java.</samp> using a
104 nested <code>&lt;propertyset/&gt;</code> which is an equivalent but longer way.</p>
105 <pre>
106 &lt;echoproperties&gt;
107 &lt;propertyset&gt;
108 &lt;propertyref prefix="java."/&gt;
109 &lt;/propertyset&gt;
110 &lt;/echoproperties&gt;</pre>
111
112 <p>Lists all properties that contain <samp>ant</samp> in their names.</p>
113 <pre>&lt;echoproperties regex=".*ant.*"/&gt;</pre>
114
115 <p>The equivalent snippet with <code>&lt;propertyset/&gt;</code> is:</p>
116 <pre>
117 &lt;echoproperties&gt;
118 &lt;propertyset&gt;
119 &lt;propertyref regex=".*ant.*"/&gt;
120 &lt;/propertyset&gt;
121 &lt;/echoproperties&gt;</pre>
122
123 </body>
124 </html>