This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 50087 - Ant and IDE disagree on semantics of <import> w/ non-"." basedir
Summary: Ant and IDE disagree on semantics of <import> w/ non-"." basedir
Status: CLOSED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Ant (show other bugs)
Version: 4.x
Hardware: All All
: P4 blocker (vote)
Assignee: Jesse Glick
URL:
Keywords:
: 50675 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-10-07 12:24 UTC by herkules
Modified: 2006-03-24 10:26 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description herkules 2004-10-07 12:24:29 UTC
The filename giving in an ant <import> statment
does not respect the value set in basedir. But NB
does!

This leads to a situation where either NB or ANT
can  evaluate the build.xml correctly, but not both :(

Consider this build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="changeme" default="all"
basedir="imports">
    <import file="imports/imptargets.xml"/>
    <target name="all" depends="imported">
    </target>
</project>

This works for ant, bc. the 'imports' value of
${basedir} is not evaluate in <import>, so the
filename of the file to be imported has to be
given completely. 

But the imported targets are not displayed in the
NB buildfile GUI. 

Changing it to 

<project name="changeme" default="all"
basedir="imports">
    <import file="imptargets.xml"/>
    <target name="all" depends="imported">
    </target>
</project>

Makes the NB-ant-GUI happy, but that file does not
 work any more:

...\test\build.xml:3: Cannot find imptargets.xml
imported from ...\test\build.xml
Comment 1 herkules 2004-10-07 12:26:11 UTC
<project name="changeme" default="all"
basedir="imports">
    <import file="${basedir}/imptargets.xml"/>
    <target name="all" depends="imported">
    </target>
</project>

This version works for ANT and is OK for NB, just the imported targets
are not shown.
Comment 2 Jesse Glick 2004-10-07 15:08:01 UTC
Well of course you should do what is correct for Ant, not for the IDE.
I wonder if the Ant behavior here is intentional or not. I will try to
find out before changing the IDE behavior.

Prefer to set basedir="." if possible, it is generally clearer anyway.
Comment 3 Jesse Glick 2004-10-26 20:52:49 UTC
*** Issue 50675 has been marked as a duplicate of this issue. ***
Comment 4 Jesse Glick 2004-10-28 21:30:56 UTC
I will fix NB's behavior to match Ant's. But beware that the docs for
<import> currently say:

Important: we have not finalized how relative file references will be
resolved in deep/complex build hierarchies - such as what happens when
an imported file imports another file. Use absolute references for
enhanced build file stability, especially in the imported files.
Comment 5 Jesse Glick 2004-10-29 15:09:33 UTC
committed   * Up-To-Date  1.5        
ant/src/org/apache/tools/ant/module/api/support/TargetLister.java
committed   * Up-To-Date  1.2        
ant/test/unit/data/targetlister/importing4.xml
committed   * Up-To-Date  1.2        
ant/test/unit/src/org/apache/tools/ant/module/api/support/TargetListerTest.java
Comment 6 Marian Mirilovic 2005-12-20 15:47:55 UTC
This issue was solved long time ago. Because nobody has reopened it neither
added comments, we are verifying/closing it now. 
If you are still able to reproduce the problem, please reopen. Thanks in advance.