alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Ant example source code file (propertyset.xml)

This example Ant source code file (propertyset.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Ant tags/keywords

apache, as, asf, asf, license, license, of, see, see, software, unless, version, you, you

The propertyset.xml source code

<!--
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You 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.
 *
-->

<project>
  <property name="fooA" value="FooA"/>
  <property name="barB" value="BarB"/>

  <propertyset id="properties-starting-with-foo">
    <propertyref prefix="foo"/>
  </propertyset>
  <propertyset id="properties-starting-with-bar">
    <propertyref prefix="bar"/>
  </propertyset>
  <propertyset id="my-set">
    <propertyset refid="properties-starting-with-foo"/>
    <propertyset refid="properties-starting-with-bar"/>
  </propertyset>
  
  <macrodef name="expect.equals">
    <attribute name="test"/>
    <attribute name="exp"/>
    <attribute name="got"/>
    <sequential>
      <fail message=
          "@{test} failed: expected "@{exp}" got "@{got}"">
        <condition>
          <not>
            <equals arg1="@{exp}" arg2="@{got}"/>
          </not>
        </condition>
      </fail>
    </sequential>
  </macrodef>

  <target name="reference-to-two-references">
    <expect.equals
      test="reference to two references"
      exp="barB=BarB, fooA=FooA"
      got="${toString:my-set}"/>
  </target>

  <target name="nested-mapped">
    <propertyset id="nested-mapped">
      <propertyset>
        <propertyset refid="properties-starting-with-foo"/>
        <globmapper from="foo*" to="boo*" />
      </propertyset>
      <propertyset>
        <propertyset refid="properties-starting-with-bar"/>
        <globmapper from="bar*" to="far*" />
      </propertyset>
    </propertyset>
    <expect.equals
      test="nested mapped propertysets"
      exp="booA=FooA, farB=BarB"
      got="${toString:nested-mapped}"/>
  </target>

  <target name="nested-mapped-mapped">
    <propertyset id="nested-mapped-mapped">
      <propertyset>
        <propertyset refid="properties-starting-with-foo"/>
        <globmapper from="foo*" to="boo*" />
      </propertyset>
      <propertyset>
        <propertyset refid="properties-starting-with-bar"/>
        <globmapper from="bar*" to="far*" />
      </propertyset>
      <mapper>
        <globmapper from="boo*" to="hoo*" />
        <globmapper from="far*" to="near*" />
      </mapper>
    </propertyset>
    <expect.equals
      test="nested mapped propertysets"
      exp="hooA=FooA, nearB=BarB"
      got="${toString:nested-mapped-mapped}"/>
  </target>

</project>

Other Ant examples (source code examples)

Here is a short list of links related to this Ant propertyset.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.