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 45066 - Valid Ant script claimed to be invalid for purposes of freeform project due to properties in <import> filename
Summary: Valid Ant script claimed to be invalid for purposes of freeform project due t...
Status: CLOSED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Ant (show other bugs)
Version: 4.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jesse Glick
URL:
Keywords:
: 45064 46722 46977 (view as bug list)
Depends on:
Blocks: 42682
  Show dependency tree
 
Reported: 2004-06-17 07:25 UTC by herkules
Modified: 2006-03-24 09:48 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Ant script not accepted as basis for a NB project (2.44 KB, text/plain)
2004-06-17 07:27 UTC, herkules
Details
Ant script not accepted as basis for a NB project (28.62 KB, text/plain)
2005-01-26 23:59 UTC, ammatsun
Details

Note You need to log in before you can comment on or make changes to this bug.
Description herkules 2004-06-17 07:25:29 UTC
In dev version 200406161800:

When creating a new project from an existing Ant 
script, the Ant script attached is reported to:

'The choosen build script is not valid Ant script'

Despite of that, standalone Ant very well works 
with that file.
Comment 1 herkules 2004-06-17 07:27:02 UTC
Created attachment 15794 [details]
Ant script not accepted as basis for a NB project
Comment 2 David Konecny 2004-06-17 09:06:32 UTC
I thought that problem is in Wizard, but the actual issue is in Ant in
TargetLister. Your imported file is defined as Ant property and
TargetLister in that case does:

throw new IOException("TargetLister does not yet handle Ant property
substs in imported file names: " + fileS + " from " + apc); // NOI18N

which in wizard I simply ignore and report as invalid Ant file.
Comment 3 Jesse Glick 2004-06-17 17:15:02 UTC
NB does not currently supported <import>ed scripts whose filename
includes Ant property references, because in general it is not
possible to find the imported file without actually running the script
(halting problem, etc.).

So the question is what to do about this.

I could change TargetLister to not throw an IOException, and just
silently ignore the <import>. That would mean that those imported
targets would never appear in the freeform project wizard/customizer,
nor in the list of targets beneath the script, nor in the Run Target
submenu, etc. Probably OK already from the Run Target submenu since
the Advanced item lets you type in a target name (the combo box is
editable). In the freeform project UI, it would mean that you would
have to make all target combo boxes editable just in case. But
potentially confusing and annoying for the user - "why don't my
imported targets appear?".

I could put in some code to try to handle *common* ways of defining
properties used in <import> filenames. At least handle simple
<property name="..." value="..."/> occurring before the <import>
statement, and perhaps also <property file="..."/>. Would be somewhat
complicated, and I would need to have the ant module depend on
ant/project (indirectly?) which currently has this evaluator logic,
and would still fail in more obscure cases (e.g. <available> and
<condition> being used to select a file to import).

I would go with the first option for now since it is much easier and
at least lets the user correct the situation manually. Maybe the
second option would be feasible but it would take some work, and there
are (IMHO) higher priority things to work on.
Comment 4 Jesse Glick 2004-06-18 01:16:10 UTC
*** Issue 45064 has been marked as a duplicate of this issue. ***
Comment 5 hanasaki 2004-06-19 00:38:36 UTC
Running "ant -f mybuild.xml -projecthelp" appears to import the other
ant files and generate the correct list of targets.  Maybe the ant
code, behind "-projecthelp" could be addapted to provide the target
lists for NB?
Comment 6 Jesse Glick 2004-06-19 01:08:55 UTC
Not easily, I think. ant -projecthelp actually runs targetless Ant
tasks such as <property>, <import>, etc. before it comes up with the
list of targets. The IDE is capable of running the Ant engine "behind
the scenes" this way, but I think it is too dangerous: the tool should
not run Ant except at the specific request of the user. Otherwise just
expanding an Ant script in the Favorites tab (e.g.) would run
arbitrary code, which could potentially have some damaging (or even
malicious) effect. It would be possible to run Ant in this mode within
a class loader given only limited permissions (e.g. applet permissions
plus arbitrary file reads) but that would be at least as much work as
just faking the result for the common cases of <property name="..."
value="..."/> and perhaps a couple others.

Also for some purposes NB needs to know additional information about
targets (e.g. defining script, description) which is more cumbersome
to extract from a live Ant run than from a direct XML parse.
Comment 7 hanasaki 2004-06-20 05:58:56 UTC
Could you make the combo boxes editable and change the error of
"invalid ant file" to a warning that allows the "next" button to be
selected?  This will allow existing build files to be used.  I am
currently the "existing" source type project and running ant from the
cmd line.
Comment 8 Jesse Glick 2004-06-20 17:25:38 UTC
Yes, as already mentioned that is simplest planned workaround.

Note that the wizard and customizer dialogs for the freeform project
are not mandatory - the project.xml can be edited directly and has no
such restrictions.
Comment 9 David Konecny 2004-06-21 08:39:18 UTC
I filed issue 45256 for myself to made combo boxes with Ant targets
editable. I hope to fix that issue later this week.
Comment 10 Jesse Glick 2004-07-30 00:13:28 UTC
*** Issue 46722 has been marked as a duplicate of this issue. ***
Comment 11 Jesse Glick 2004-07-30 00:26:04 UTC
Attached script in issue #46722 is especially disconcerting because it
uses <property environment="env"/>, certainly more obscure than I
would consider simulating. ant -projecthelp on it just shows an error
if your environment variables are not correctly configured!

I can put in a patch that just ignores any <import> statements using
property substitutions. Impact:

1. You will not be able to choose targets from those imported scripts
using the target mapping panel in the new freeform project wizard (nor
in the corresponding panel in the customizer after you make the project).

2. Those targets will not appear as subitems of the script in the
Files tab, nor in the Run Target context menu item.

On the other hand:

3. You could manually edit project.xml to set up target mappings for a
freeform project, and they should work.

4. You can type in any target name in the Advanced panel of the Run
Target context menu.

5. For any commonly desired targets, you can also redefine in the main
script so that NetBeans sees them, as follows:

<import name="${whatever.xml}"/>
<!-- ... -->
<target name="stuff" depends="whatever.stuff"/>
Comment 12 Jesse Glick 2004-07-30 18:37:05 UTC
*** Issue 46722 has been marked as a duplicate of this issue. ***
Comment 13 Jesse Glick 2004-07-30 19:40:27 UTC
committed     Up-To-Date  1.4        
ant/src/org/apache/tools/ant/module/api/support/TargetLister.java
Comment 14 Jesse Glick 2004-08-06 21:01:59 UTC
*** Issue 46977 has been marked as a duplicate of this issue. ***
Comment 15 ammatsun 2005-01-26 23:59:25 UTC
Created attachment 19990 [details]
Ant script not accepted as basis for a NB project
Comment 16 ammatsun 2005-01-27 00:04:40 UTC
The attached file is used by Axis 1.2 RC2 and it is also not accepted 
by NB 4.0. It does not contain an <import> but it uses XML's way of 
including external files. Is this the cause for the problem?
Comment 17 Jesse Glick 2005-01-28 02:16:43 UTC
ammatsun: the attached build script is invalid; please remove the
unnecessary and incorrect "file:" prefixes from the relative URIs in
the entity includes and it should be OK.
Comment 18 Jesse Glick 2005-08-29 18:35:22 UTC
See issue #62752: computed filenames in <import> now supported for many common
cases. (Not yet <property env="..."> however.)
Comment 19 Marian Mirilovic 2005-12-20 15:48:59 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.