Browse Source

fix xmlproperty examples. PR 43583

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@794666 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
30ebea71bb
2 changed files with 90 additions and 14 deletions
  1. +13
    -13
      docs/manual/CoreTasks/xmlproperty.html
  2. +77
    -1
      src/tests/antunit/taskdefs/xmlproperty-test.xml

+ 13
- 13
docs/manual/CoreTasks/xmlproperty.html View File

@@ -237,7 +237,7 @@ is equivalent to the following properties:

<h5>default loading (semanticAttributes=true)</h5>
<p>This entry in a build file:
<pre> &lt;xmlproperty file="somefile.xml"
<pre> &lt;xmlproperty file="somefile.xml" keepRoot="false"
semanticAttributes="true"/&gt;</pre>
is equivalent to the following entries in a build file:
<pre>
@@ -246,22 +246,22 @@ is equivalent to the following entries in a build file:
&lt;property name="build.classes" location="${build.folder}/classes" id="build.classes"/&gt;
&lt;property name="build.reference" refid="build.classes"/&gt;

&lt;property name="run-time.jars" value="*.jar/&gt;
&lt;property name="run-time.jars" value="*.jar"/&gt;

&lt;classpath id="compile.classpath"&gt;
&lt;path id="compile.classpath"&gt;
&lt;pathelement location="${build.classes}"/&gt;
&lt;/classpath&gt;
&lt;/path&gt;

&lt;classpath id="run-time.classpath"&gt;
&lt;path id="run-time.classpath"&gt;
&lt;path refid="compile.classpath"/&gt;
&lt;pathelement path="${run-time.jars}"/&gt;
&lt;/classpath&gt;
&lt;/path&gt;
</pre>

<h5>includeSemanticAttribute="true"</h5>
<p>This entry in a build file:
<pre> &lt;xmlproperty file="somefile.xml"
semanticAttributes="true"
semanticAttributes="true" keepRoot="false"
includeSemanticAttribute="true"/&gt;
</pre>
is equivalent to the following entries in a build file:
@@ -269,18 +269,18 @@ is equivalent to the following entries in a build file:
&lt;property name="version.value" value="0.0.1"/&gt;
&lt;property name="build.folder" value="build"/&gt;
&lt;property name="build.classes.location" location="${build.folder}/classes"/&gt;
&lt;property name="build.reference.refid" refid="build.location"/&gt;
&lt;property name="build.reference.refid" refid="build.classes"/&gt;

&lt;property name="run-time.jars" value="*.jar/&gt;
&lt;property name="run-time.jars" value="*.jar"/&gt;

&lt;classpath id="compile.classpath"&gt;
&lt;path id="compile.classpath"&gt;
&lt;pathelement location="${build.classes}"/&gt;
&lt;/classpath&gt;
&lt;/path&gt;

&lt;classpath id="run-time.classpath"&gt;
&lt;path id="run-time.classpath"&gt;
&lt;path refid="compile.classpath"/&gt;
&lt;pathelement path="${run-time.jars}"/&gt;
&lt;/classpath&gt;
&lt;/path&gt;
</pre>




+ 77
- 1
src/tests/antunit/taskdefs/xmlproperty-test.xml View File

@@ -15,8 +15,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns:au="antlib:org.apache.ant.antunit">
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<description/>

<import file="../antunit-base.xml" />

<target name="test-empty">
<xmlproperty file="xmlproperty-test.xml"/>
<au:assertTrue>
@@ -64,5 +67,78 @@
</condition>
</fail>
</target>

<target name="createDocExample">
<mkdir dir="${input}"/>
<echoxml file="${input}/example.xml">
<root-tag>
<version value="0.0.1"/>
<build folder="build">
<classes id="build.classes" location="${build.folder}/classes"/>
<reference refid="build.classes"/>
</build>
<compile>
<classpath pathid="compile.classpath">
<pathelement location="${build.classes}"/>
</classpath>
</compile>
<run-time>
<jars>*.jar</jars>
<classpath pathid="run-time.classpath">
<path refid="compile.classpath"/>
<pathelement path="${run-time.jars}"/>
</classpath>
</run-time>
</root-tag>
</echoxml>
</target>

<target name="testSemanticLoadingDocExample" depends="createDocExample">
<xmlproperty file="${input}/example.xml" semanticAttributes="true"
keepRoot="false"/>

<au:assertPropertyEquals name="version" value="0.0.1"/>
<au:assertPropertyEquals name="build.folder" value="build"/>
<property name="b.c" location="${build.folder}/classes"/>
<au:assertPropertyEquals name="build.classes" value="${b.c}"/>
<au:assertReferenceSet refid="build.classes"/>
<property name="b.c.r" refid="build.classes"/>
<au:assertPropertyEquals name="b.c.r" value="${b.c}"/>
<au:assertPropertyEquals name="build.reference" value="${b.c}"/>
<au:assertPropertyEquals name="run-time.jars" value="*.jar"/>
<au:assertReferenceIsType refid="compile.classpath" type="path"/>
<au:assertReferenceIsType refid="run-time.classpath" type="path"/>
<property name="c.c" refid="compile.classpath"/>
<au:assertPropertyEquals name="c.c" value="${b.c}"/>
<property name="rt.c" refid="run-time.classpath"/>
<property name="glob.dot.jar" location="*.jar"/>
<au:assertPropertyEquals name="rt.c"
value="${b.c}${path.separator}${glob.dot.jar}"/>
</target>

<target name="testIncludeSemanticDocExample" depends="createDocExample">
<xmlproperty file="${input}/example.xml" semanticAttributes="true"
keepRoot="false" includeSemanticAttribute="true"/>

<au:assertPropertyEquals name="version.value" value="0.0.1"/>
<au:assertPropertyEquals name="build.folder" value="build"/>
<property name="b.c" location="${build.folder}/classes"/>
<au:assertPropertyEquals name="build.classes.location" value="${b.c}"/>
<au:assertReferenceSet refid="build.classes"/>
<property name="b.c.r" refid="build.classes"/>
<au:assertPropertyEquals name="b.c.r" value="${b.c}"/>
<au:assertPropertyEquals name="build.reference" value="${b.c}"/>
<au:assertPropertyEquals name="run-time.jars" value="*.jar"/>
<au:assertReferenceIsType refid="compile.classpath" type="path"/>
<au:assertReferenceIsType refid="run-time.classpath" type="path"/>
<property name="c.c" refid="compile.classpath"/>
<!-- not set at all because property's name is build.classes.refid now -->
<property name="b.c.loc" location="${build.classes}"/>
<au:assertPropertyEquals name="c.c" value="${b.c.loc}"/>
<property name="rt.c" refid="run-time.classpath"/>
<property name="glob.dot.jar" location="*.jar"/>
<au:assertPropertyEquals name="rt.c"
value="${b.c.loc}${path.separator}${glob.dot.jar}"/>
</target>
</project>


Loading…
Cancel
Save