ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Ivanov <>
Subject Basedir of imported file replaced with basedir of importing file
Date Thu, 24 Jun 2004 06:48:46 GMT
Dear Colleagues,

I am having some issues when using <import> task and I
would be very grateful if you help me to resolve them.
The scenario is the following:

I created an ant build xml called jalopy.xml[1] which
<taskdef> jalopy task (Jalopy is a source code
formatter). The paths to the jalopy distribution and
jalopy lib  are moved to an external properties file
called[2]. Both jalopy.xml and are in one dir. I also created a
macrodef that uses <jalopy> task.

I tried to designed jalopy.xml script to be applicable
to all our projects. What one needs to do to use is
simply to checkout the script and properties from CVS
anywhere she wants on her file system, change the
properties in, <import> jalopy.xml
and start using the macrodef. For example, this is a
sample use of it for the project MyProj:

<project name="MyProject" basedir="." default="usage">
    <target name="usage"/>
    <import file="${jalopy.commons.dir}/jalopy.xml"

    <target name="format-src"
depends="compile,-jalopy.init" description="Formats
the project's java sources">
   	<path id="project.classpath">
   	    <path refid="classpath"/>
   	    <path location="${project.classes}"/>
	<fileset dir="${project.src}" id="">
            <include name="**/*.java" />

The problem with this is that when I call 
<property file="${basedir}/"> in
jalopy.xml, ${basedir} property is resolved against
MyProject, and not against jalopy.xml. So is not found and the build failed

Of course, I workarounded it but it is not beautifull
any more. This is only because the basedir of the
imported file is replaced with basedir of the
importing file. Is it a bug or it is done by design
and intention? And is it possible to implement my idea
in this way?

[1] jalopy.xml
<project name="SourceFormatter" default="usage"
    <target name="usage"/>
    <target name="-jalopy.init"
description="Initializes the needed properties and

<import file="${jalopy.dir}/jalopy.xml"
        <!-- Import Jalopy Settings -->
        <property file="${basedir}/">
	<taskdef name="jalopy"	     
	    	<fileset dir="${jalopy.dir.lib}">
	      	    <include name="*.jar" />

   	<macrodef name="format-jalopy"
description="Formats java sources with jalopy">
   	    <attribute name="classpathref" default=""
description="Reference to classpath, used for
   	    <attribute name="srcref"
description="Reference to a fileset, describing the
sources to format"/>
convention="${basedir}/mycc.xml" force="yes"
		    <fileset refid="@{srcref}"/>


and mycc.xml is the xml represantation of my code
conventions against which the code will be formatted.

# Jalopy root directory
# Jalopy library directory

Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message