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

Ant example source code file (addtype.xml)

This example Ant source code file (addtype.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

abimpl, addtypetest, addtypetest, aimpl, cimpl, myaddconfiguredvalue, mycondition, mycondition, myvalue, nestedcontainer, set, set, this, this

The addtype.xml source code

<project name="test" basedir=".">

  <target name="addpath">
    <typedef name="mypath" classname="org.apache.tools.ant.types.Path"/>
    <path>
      <mypath path="build.xml"/>
    </path>
  </target>

  <target name="addcondition">
    <typedef name="mycondition"
             classname="org.apache.tools.ant.taskdefs.condition.Equals"/>
    <condition property="mycondition.set">
      <mycondition arg1="string" arg2="string"/>
    </condition>
    <fail unless="mycondition.set"/>
  </target>

  <target name="addfilter">
    <typedef name="headfilter2"
             classname="org.apache.tools.ant.filters.HeadFilter"/>
    <concat>This is line 1
      This is line 2
      This is line 3
      <filterchain>
        <headfilter2 lines="2"/>
      </filterchain>
    </concat>
  </target>

  <target name="addselector">
    <typedef
      name="myselector"
      classname="org.apache.tools.ant.types.selectors.ContainsSelector"/>
    <fileset id="myselector.test" dir="${basedir}" includes="*">
      <myselector text="myselector"/>
    </fileset>
  </target>

  <target name="init">
    <property name="nested.package" value="org.apache.tools.ant.types."/>
    <path id="test-classes">
      <pathelement location="../../../../build/testcases" />
      <pathelement path="${java.class.path}" />
    </path>
    <typedef loaderref="nested.loader" classpathref="test-classes"
             name = "nested.a"
             classname="${nested.package}AddTypeTest$AImpl"/>
    <typedef loaderref="nested.loader"
             name = "nested.b"
             classname="${nested.package}AddTypeTest$BImpl"/>
    <typedef loaderref="nested.loader"
             name = "nested.c"
             classname="${nested.package}AddTypeTest$CImpl"/>
    <typedef loaderref="nested.loader"
             name = "nested.ab"
             classname="${nested.package}AddTypeTest$ABImpl"/>
    <taskdef loaderref="nested.loader"
             name = "nested.container" 
             classname="${nested.package}AddTypeTest$NestedContainer"/>
    <taskdef loaderref="nested.loader"
             name = "nested.condition.task" 
             classname="${nested.package}AddTypeTest$MyCondition"/>
    <typedef loaderref="nested.loader"
             name = "nested.condition.type" 
             classname="${nested.package}AddTypeTest$MyCondition"/>
    <typedef loaderref="nested.loader"
             name = "myaddconfigured" 
             classname="${nested.package}AddTypeTest$MyAddConfigured"/>
    <typedef loaderref="nested.loader"
             name = "myaddconfiguredvalue" 
             classname="${nested.package}AddTypeTest$MyAddConfiguredValue"/>
    <typedef loaderref="nested.loader"
             name = "myvalue" 
             classname="${nested.package}AddTypeTest$MyValue"/>
  </target>

  <target name="nested.a" depends="init">
    <nested.container>
      <nested.a/>
    </nested.container>
  </target>

  <target name="nested.b" depends="init">
    <nested.container>
      <nested.b/>
    </nested.container>
  </target>
  
  <target name="nested.c" depends="init">
    <nested.container>
      <nested.c/>
    </nested.container>
  </target>

  <target name="nested.ab" depends="init">
    <nested.container>
      <nested.ab/>
    </nested.container>
  </target>

  <!-- tests for task adaptor -->
  <target name="condition.type" depends="init">
    <echo>before
    <nested.condition.type/>
    <echo>after
  </target>

  <target name="condition.task" depends="init">
    <echo>before
    <nested.condition.task/>
    <echo>after
  </target>

  <target name="condition.condition.type" depends="init">
    <condition property="condition.condition.type">
      <nested.condition.type/>
    </condition>
  </target>

  <target name="condition.condition.task" depends="init">
    <condition property="condition.condition.task">
      <nested.condition.task/>
    </condition>
  </target>

  <target name="myaddconfigured" depends="init">
    <myaddconfigured>
      <myvalue>Value Set
    </myaddconfigured>
  </target>

  <target name="myaddconfiguredvalue" depends="init">
    <myaddconfiguredvalue>
      <value>Value Set
    </myaddconfiguredvalue>
  </target>

  <target name="namespacetest" xmlns:prefix="uri">
    <typedef name="eq" uri="uri"
             classname="org.apache.tools.ant.taskdefs.condition.Equals"/>
    <condition property="p">
      <prefix:eq arg1="a" arg2="b"/>
    </condition>
  </target>
</project>

Other Ant examples (source code examples)

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

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

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 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.