| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Ant example source code file (echo.xml)

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

Java - Ant tags/keywords

appended, appended, did, echo, of, output, simple, simple, this, utf-16, utf16, utf16, utf8, utf8

The echo.xml source code

<?xml version="1.0"?>

<project name="echo-test" basedir="." default="test1">

  <property name="dest.dir" location="echo.dest"/>

  <target name="init">
    <mkdir dir="${dest.dir}" />

  <target name="clean">
    <delete dir="${dest.dir}"/>

  <target name="test1">

  <target name="test2">
    <echo message="OUTPUT OF ECHO"/>

  <target name="test3">

  <macrodef name="assertContains">
    <attribute name="expected" />
    <attribute name="actual" />
            <contains string="@{actual}" substring="@{expected}">
        Did not find @{expected} in @{actual}

  <target name="testFile" depends="init">
    <echo file="${dest.dir}/echo.txt">Simple text
    <loadfile srcfile="${dest.dir}/echo.txt" property="echo" />
    <assertContains actual="${echo}" expected="Simple text" />

  <target name="testAppend" depends="init">
    <echo file="${dest.dir}/echo.txt">Simple text
    <echo file="${dest.dir}/echo.txt" append="true">Appended
    <loadfile srcfile="${dest.dir}/echo.txt" property="echo"/>
    <assertContains actual="${echo}" expected="Simple text"/>
    <assertContains actual="${echo}" expected="Appended"/>

  <target name="testEmptyEncoding" depends="init">
    <echo file="${dest.dir}/echo.txt" encoding="">Simple text
    <loadfile srcfile="${dest.dir}/echo.txt" property="echo"/>
    <assertContains actual="${echo}" expected="Simple text"/>

  <target name="testUTF16Encoding" depends="init">
    <property name="char" value="©" />
    <echo file="${dest.dir}/echo16.txt" encoding="UTF-16">${char}
    <loadfile srcfile="${dest.dir}/echo16.txt" property="echo16" encoding="UTF16"/>
    <assertContains actual="${echo16}" expected="${char}"/>
  <target name="testUTF8Encoding" depends="init">
    <property name="char" value="©" />
    <echo file="${dest.dir}/echo8.txt" encoding="UTF8">${char}
    <loadfile srcfile="${dest.dir}/echo8.txt" property="echo" encoding="UTF8"/>
    <assertContains actual="${echo}" expected="${char}"/>


Other Ant examples (source code examples)

Here is a short list of links related to this Ant echo.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,
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.