"basedir" appears to be derived by countin slashes from current directory instead of counting up for each slash, down for ".." and no change for each "." In particular, for file ~/j/src/ca/gorman/io/build.xml, "ant clean" works from ~/j/src/ca/gorman/io "ant -f io/build.xml clean" works from ~/j/src/ca/gorman "ant -f ../io/build.xml clean" fails from ~/j/src/ca/gorman/xml A console log follows. The echo line reports ${basedir} and the exec line is executing a "pwd". Ian E. gorman ian@iosphere.net ian@ian:~/j/src/ca/gorman/io >ant -version Apache Ant version 1.6.1beta1 compiled on January 29 2004 ian@ian:~/j/src/ca/gorman/io >ant clean Buildfile: build.xml init: [echo] /home/ian/j/src [exec] /home/ian/j/src setup: clean: clean: BUILD SUCCESSFUL Total time: 3 seconds ian@ian:~/j/src/ca/gorman/io >cd .. ian@ian:~/j/src/ca/gorman >ant -f io/build.xml clean Buildfile: io/build.xml init: [echo] /home/ian/j/src [exec] /home/ian/j/src setup: clean: clean: BUILD SUCCESSFUL Total time: 3 seconds ian@ian:~/j/src/ca/gorman >cd xml ian@ian:~/j/src/ca/gorman/xml >ant -f ../io/build.xml clean Buildfile: ../io/build.xml init: [echo] /home/ian/j/src/ca/gorman [exec] /home/ian/j/src/ca/gorman setup: clean: BUILD FAILED /home/ian/j/src/ca/gorman/io/build.xml:80: Basedir /home/ian/j/src/ca/gorman/ca/gorman/io/demo/doc-files does not exist Total time: 1 second ian@ian:~/j/src/ca/gorman/xml >
Could you please attach your build file? Things seem to work for me.
Build files have been modified since last report. I have appended a copy of the file that produced the following result: ian@ian:~/j/src/ca/gorman/xml >ls ../build.xml ../build.xml ian@ian:~/j/src/ca/gorman/xml >ant ../build.xml clean Buildfile: build.xml does not exist! Build failed ian@ian:~/j/src/ca/gorman/xml > ======= build file ===================================== <!-- $Id: build.xml,v 1.1 2004/02/10 20:32:55 ian Exp $ "ant" build file for GXPARSE This file is part of GXPARSE, a general XML parser API. Copyright (C) 2003, 2004 Ian E. Gorman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or go to http://www.gnu.org/ --> <!-- Build package ca.gorman.xml.parse and subpackages This file should be in the same directory as the Java source files, but can be run from any directory. Targets that can be used from command line clean remove all generated files and directories compile compile to classes to test directories javadoc generate javadoc for end user javadoc_all generate javadoc for developer ship pack for shipping to end user setup create all destination directories Targets that should not be used from command line init Ian E. Gorman --> <project name="build_all" default="default" basedir="./../.."> <property name="xml.parse.build.file" value="${basedir}/ca/gorman/xml/parse/build.xml" description="xml parse build file"/> <property name="io.build.file" value="${basedir}/ca/gorman/io/build.xml" description="io build file"/> <target name="init"> <tstamp/> </target> <target name="default" description="Command line help"> <echo>Build package ${package.name}</echo> <echo>Use "-projecthelp" option to get a list of targets</echo> <echo>Additional info in file comments</echo> </target> <!-- define destination directories --> <property name="source.dir" value="${basedir}" description="java source base directory"/> <property name="lib.dir" value="${basedir}/../lib" description="library base directory" /> <property name="class.dir" value="${basedir}/../cls" description="class base directory" /> <property name="doc.dir" value="${basedir}/../doc" description="javadoc base directory"/> <property name="ship.dir" value="${basedir}/../ship" description="staging and shipping directory"/> <property name="doc.ship.dir" value="${ship.dir}/doc" description="staging and shipping directory"/> <property name="lib.ship.dir" value="${ship.dir}/lib" description="staging and shipping directory"/> <property name="src.ship.dir" value="${ship.dir}/src" description="staging and shipping directory"/> <!-- create destination directories --> <target name="setup" depends="init" description="Create target directories"> <mkdir dir="${class.dir}"/> <mkdir dir="${doc.dir}"/> <mkdir dir="${lib.dir}"/> <mkdir dir="${ship.dir}"/> </target> <!-- remove destination directories and generated files --> <target name="clean" description="Remove targets"> <ant antfile="${io.build.file}" target="clean" inheritall="true" description="package ca.gorman.io"/> <ant antfile="${xml.parse.build.file}" target="clean" inheritall="false" description="package ca.gorman.xml.parse"/> </target> <!-- compile --> <target name="compile" depends="setup" description="Compile source files to classes"> <ant antfile="${io.build.file}" target="compile" inheritall="false" description="package ca.gorman.io"/> <ant antfile="${xml.parse.build.file}" target="compile" inheritall="false" description="package ca.gorman.xml.parse"/> </target> <!-- build --> <target name="build" depends="clean, compile" description="clean, then compile source files to classes"/> <!-- document --> <target name="javadoc" depends="build" description="Build, then create javadoc for end user"> <javadoc classpath="${class.dir}" author="false" private="false" additionalparam="-source 1.4 -quiet" destdir="${doc.dir}"> <link href="http://java.sun.com/j2se/1.4.2/docs/api/"/> <package name="ca.gorman.io.*"/> <package name="ca.gorman.xml.parse.*"/> <sourcepath location="${source.dir}"/> <classpath location="${class.dir}"/> </javadoc> </target> <!-- document --> <target name="javadoc_all" depends="build" description="Build, then create javadoc with all information"> <javadoc classpath="${class.dir}" author="true" private="true" additionalparam="-source 1.4 -quiet" destdir="${doc.dir}"> <link href="http://java.sun.com/j2se/1.4.2/docs/api/"/> <package name="ca.gorman.io.*"/> <package name="ca.gorman.xml.parse.*"/> <sourcepath location="${source.dir}"/> <classpath location="${class.dir}"/> </javadoc> <copy description="Supplementary files for ca.gorman" todir="${doc.dir}/ca/gorman/doc-files"> <fileset dir="${source.dir}/ca/gorman/doc-files"/> </copy> </target> <target name="shipdoc" depends="javadoc"> <!-- description="Prepare to ship docs"--> <delete dir="${doc.ship.dir}" failonerror="false"/> <mkdir dir="${doc.ship.dir}"/> <copy todir="${doc.ship.dir}" preservelastmodified="true"> <fileset dir="${doc.dir}"/> </copy> </target> <target name="ship" depends="shipdoc" description="Pack for shipment to end user"> </target> </project> ====================================================================
I got this problem to happen: a build file containing: <project basedir="../.."> <echo>basedir is "${basedir}"</echo> </project> ~/learning/a/dotdot/j/src/ca/gorman/io > ant -f build.xml basedir is "/home/preilly/learning/a/dotdot/j/src/ca" ~/learning/a/dotdot/j/src/ca/gorman/io > ant -f ../io/build.xml basedir is "/home/preilly/learning/a/dotdot/j/src/ca/gorman/io" The problem is that ProjectHelper2 uses File#getAbsolutePath(). getAbsolutePath() does not resolve .. and . in the filename, so later when FileUtils.resolveFile is used, it generates an incorrect path. The solution was to call FileUtils#normalize() on the filename.