ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leif Hanack" <>
Subject Problem with <dirname/>
Date Wed, 02 Apr 2003 12:17:27 GMT

i have some problems with the dirname task. When calling the script below i
receive the following.
copyDate is a batch file that call my ant-script. The source dir is set to
the base dir of my script, but in this case i want to have a empty value for
source.dir. Is this possible?

Thanks in advance, Leif

c:\System\Utility>copyDate someDir

c:\System\Utility>ant -f
C:\System\Utility\antTasks\copy.xml -Dsource=someDir
Buildfile: C:\System\Utility\antTasks\copy.xml


     [echo] source     : someDir
     [echo] source dir : C:\System\Utility\antTasks
     [echo] source name: someDir
     [echo] target: C:\System\Utility\antTasks/20030402_0149_someDir


file:C:/System/Utility/antTasks/copy.xml:42: Warning: Could not find file
tem\Utility\antTasks\someDir to copy.

Here is the script:

<?xml version="1.0"?>

<project name="copy" basedir="." default="build">

    <target name="init" description="initialize copy">
        <!-- file or directory to copy -->
        <property name="source" value=""/>

            <format property="date" pattern="yyyyMMdd_hhmm"/>

    <target name="copy" depends="init" if="source" description="">

        <basename property="" file="${source}" />
        <dirname property="source.dir" file="${source}"/>
        <echo message="source     : ${source}" />
        <echo message="source dir : ${source.dir}" />
        <echo message="source name: ${}" />

        <!-- sets kind to DIR if source type is 'dir' -->
        <available property="kind" type="dir" value="DIR" file="${source}"
        <!-- otherwise -->
        <property name="kind" value="FILE" />

        <property name="target" value="${source.dir}/${date}_${}"
        <echo message="target: ${target}" />

        <antcall target="copy-${kind}"/>

    <target name="copy-DIR">
        <copy todir="${target}">
            <fileset dir="${source}"/>

    <target name="copy-FILE">
        <copy file="${source}" tofile="${target}"/>

    <target name="build" depends="init,copy" description="">


View raw message