You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2006/10/04 20:13:33 UTC

DO NOT REPLY [Bug 37694] - Calling ant via java sets "basedir" property to where the build file lives - undocumented.

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37694>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37694


andreas.krueger@dv-ratio.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Calling ant via java does   |Calling ant via java sets
                   |not set "basedir" property  |"basedir" property to where
                   |                            |the build file lives -
                   |                            |undocumented.




------- Additional Comments From andreas.krueger@dv-ratio.com  2006-10-04 11:13 -------
Peter - your build file runs with no problems.

The good news: I cannot produce my own problem precisely, as described almost a
year ago. So I take the liberty of renaming the bug, from "does not set basedir"
to "sets ... - undocumented".

I tried the following:

I have a directory, with three contents:

Firstly, it has a file parent.xml, which looks like this:

<project default="call">

    <target name="call">
        <fail message="ant.home not set."
            unless="ant.home" />
        <property name="sub.builddir" location="." />
        <property name="sub.buildfile" location="../subfile.xml" />

        <echo>basedir is ${basedir}</echo>
        <echo>sub.builddir is ${sub.builddir}</echo>
        <echo>sub.buildfile is ${sub.buildfile}</echo>

        <java
            classname="org.apache.tools.ant.launch.Launcher"
            fork="true"
            failonerror="true"
            dir="${sub.builddir}"
            timeout="4000000"
            >
            <classpath>
                <pathelement location="${ant.home}/lib/ant-launcher.jar"/>
            </classpath>
            <arg value="-buildfile"/><arg file="${sub.buildfile}"/>
            <arg value="callee"/>
        </java>
        
    </target>

</project>

Secondly, it has a file subfile.xml, which looks like this:

<project>

    <target name="callee">
        <echo>basedir is ${basedir}</echo>
    </target>

</project>

And finally, that directory has a sub directory "subdir".

I change into that sub directory, and call

ant -Dbasedir=. -buildfile ../parent.xml

I have not found a way to predict, from the documentation, what callee will show
as its subdir.

Here is what indeed does happen, as of ant 1.6.5 :

$ ant -Dbasedir=. -buildfile ../parent.xml
Buildfile: ../parent.xml

call:
     [echo] basedir is .
     [echo] sub.builddir is /home/andreas/radio/comp/ant/antbug/subdir
     [echo] sub.buildfile is /home/andreas/radio/comp/ant/antbug/subfile.xml
     [java] Buildfile: /home/andreas/radio/comp/ant/antbug/subfile.xml

     [java] callee:
     [java]      [echo] basedir is /home/andreas/radio/comp/ant/antbug

     [java] BUILD SUCCESSFUL
     [java] Total time: 0 seconds

BUILD SUCCESSFUL
Total time: 4 seconds

So, through the call to <java>, the build's basedir climbed one level up.

>From other experiments, it seems that I always get, as the basedir, the
directory that contains the sub buildfile. The value I hand down through
<java dir=""> seems to be ignored.

I don't mind this particular behaviour of ant. But I suggest this behaviour
should be documented.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org