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 43871 - Cannot create Ant build.xml outside of a project without restarting
Summary: Cannot create Ant build.xml outside of a project without restarting
Status: RESOLVED DUPLICATE of bug 51978
Alias: None
Product: projects
Classification: Unclassified
Component: Generic Infrastructure (show other bugs)
Version: 4.x
Hardware: All All
: P4 blocker (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-26 12:45 UTC by Milan Kubec
Modified: 2008-10-14 13:18 UTC (History)
6 users (show)

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 Milan Kubec 2004-05-26 12:45:01 UTC
[custom build 20040526, JDK 1.4.2]
User is not able to create ant build script out of
the project on tab Favorites and use it. In fact
user is able to create a file build.xml but he
cannot do any ant script specific actions on it.
Comment 1 Jesse Glick 2004-05-26 15:58:31 UTC
You would need to restart the IDE.

Not straightforward to fix currently since the check for the MIME type
of the file is done when it is created, at which time it is empty and
thus cannot be known to be an Ant script as opposed to any other XML
file. There is no API in Filesystems to have the MIME type be
recalculated due to changes in file content. Ideally the core
MIMEResolver impl would track files for which
FileObject.getInputStream was used (due to content-matching patterns)
and recheck the MIME type after file modifications. Then there would
also need to be some API to refresh MIME type of the file, which
Datasystems would have to listen to.
Comment 2 Milan Kubec 2004-05-27 08:58:36 UTC
I see this as P2 - in fact not being able to create ant build script
and use it. It was esential feature in 3.6. Restarting is not a
workaround - we can't require restart to create a build script (it
sounds to windows-ish :). One very easy fix would be to allow to
create any file outside of project that do not require project context
- such files are listed as Supported in UI Spec:

[f] XML
 |- [t] XML Document
 |- [t] DTD Entity
 |- [t] XML Schema
 |- [t] XSL Stylesheet
 |- [t] OASIS XML Catalog
 |- [t] XML Parsed Entity
 -- [t] Cascading Style Sheet

[f] Ant Build Scripts
 |- [t] Blank Ant Project
 |- [t] Sample Ant Project
 -- [t] Custom Task

[f] Other
 |- [t] Web Bookmark
 |- [t] Group of Files
 |- [t] HTML File
 |- [t] Properties File
 -- [t] Text File

(Not sure about Group of files).

This way nobody will need post-creation MIME resolver and any
potentional problems will be resolved because user would create what
he really wants (because there might be more file types with extension
xml which require own handling, not only ant build scripts).
Comment 3 Jesse Glick 2004-05-27 09:17:59 UTC
The trouble is defining exactly what kinds of files require a "project
context". Ant Task needs a classpath and so is not appropriate here.
Some of the templates listed require special wizard iterators, e.g.
XML Document. I suppose there could be a special template category for
templates which can be created in any folder. Request comment from
Petr and Jano. I am not sure we have time to do this for D however.

Perhaps this was an "essential feature" in NB 3.6 but I don't think
that is true now. Still consider this P3.
Comment 4 Milan Kubec 2004-05-27 09:37:35 UTC
Jano and Petr please could you comment. Thanks.
Comment 5 rmatous 2004-05-27 10:43:37 UTC
Priority <= P3 for me.
Comment 6 Milan Kubec 2004-05-27 11:28:22 UTC
It might look from developers point of view, but certainly not from
users point of view. User is simply not able to create Ant script on
disk by IDE that is completly based on Ant. Moreover the IDE looks
different after restart - before restart the file is XML - after
restart it's Ant build script - what would it be after next restart
(user might ask).
Comment 7 _ ttran 2004-06-20 22:38:10 UTC
can we special case for file named build.xml?

Comment 8 rmatous 2004-06-21 07:15:37 UTC
Frankly I don't like these sixth sense solutions that cause even more
confusion for users. 
Comment 9 Milan Kubec 2004-06-21 07:50:07 UTC
Well, but there should be some solution, because when I wanted to
create Ant build script out of a project I had to start NB 3.6, which
is not what we would like users to do.
Comment 10 jrojcek 2004-06-21 12:17:30 UTC
I think the only way how to fix this correctly is to do what Milan suggested.

OTOH I disagree with saying that "User is simply not able to create Ant script on disk by 
IDE that is completly based on Ant.". The IDE is *not* based on Ant, the project system 
that you don't want to use is based on Ant.

Btw, what is your build script doing that you don't want to use the project system?
Comment 11 Milan Kubec 2004-06-21 12:58:28 UTC
I was creating various Ant scripts for testing purposes.
Comment 12 rmatous 2004-06-21 13:38:11 UTC
Workaround:
- open favourites tab 
- find arbitrary ant script (the best is to put one empty ant script
into home dir which is present in favourites tab as default)
- copy and paste 
- edit


Then you don't need to switch into NB 3.6 and also I hope you could
accept that there isn't possible to deliver everything in one release.
Comment 13 Milan Kubec 2004-06-21 13:44:08 UTC
We should put this into Release Notes, ... users will surely love it :-)
Comment 14 jrojcek 2004-06-21 13:47:00 UTC
Milan, could you please elaborate what the build script is doing? What target it has, etc. Or 
you might attach one.
Comment 15 Petr Hrebejk 2004-06-21 13:47:48 UTC
Hmm, it is not nice but it looks like we'll have to live with that in
D. (users will have to use Radek's workaround) We might fix it by some
marker on templates in E or F. But in fact we should reather fix the
problem with the MIME resolver. Because it is the root cause of the
problem. The trouble is that it might be a bit harder than fixing
templates.
Comment 16 Jesse Glick 2004-06-21 19:00:00 UTC
For some reason it seems that copying a new XML file to which you have
added a minimum Ant header does *not* make the copy an Ant script.
Odd. Some unwanted hack in Datasystems perhaps?
Comment 17 Jesse Glick 2004-06-21 19:02:25 UTC
Another possible workaround: have Ant module recognize all files named
"build.xml" regardless of contents. Then if you need a file of a
different name, you could make it as "build.xml" and rename it later
when you have a valid Ant header.
Comment 18 Jesse Glick 2004-07-07 17:12:58 UTC
Another workaround: copy the Ant script template from Templates in the
Options dialog and paste into the desired folder, then rename and edit
as needed.
Comment 19 Jesse Glick 2004-08-14 16:35:32 UTC
I will special-case the name "build.xml" for D. Better than nothing I
think.
Comment 20 Jesse Glick 2004-08-18 22:55:25 UTC
Now you can create an empty file "build.xml" (must be exactly that
name) and all should work normally.

committed   * Up-To-Date  1.23       
ant/src/org/apache/tools/ant/module/loader/AntProjectDataLoader.java
committed   * Up-To-Date  1.30       
ant/src/org/apache/tools/ant/module/xml/AntProjectSupport.java
added       * Up-To-Date  1.1        
ant/test/unit/src/org/apache/tools/ant/module/xml/AntProjectSupportTest.java
Comment 21 Antonin Nebuzelsky 2008-04-15 17:16:11 UTC
Reassigning to new module owner jskrivanek.
Comment 22 Jiri Skrivanek 2008-09-02 15:39:02 UTC
Use case seems to be obsolete now.
Comment 23 Jesse Glick 2008-09-10 04:33:15 UTC
I think this is still valid. It may be a duplicate of some more general issue that you should be able to create
non-project-dependent templates in the Favorites tab. (We need an API for templates to indicate that they can safely be
run with no associated project.)
Comment 24 Milos Kleint 2008-10-14 13:18:41 UTC
duplicate of issue 51978

*** This issue has been marked as a duplicate of 51978 ***