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 58467 - Cannot create a new freeform project inside of another project
Summary: Cannot create a new freeform project inside of another project
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Ant Freeform (show other bugs)
Version: 4.x
Hardware: All All
: P1 blocker (vote)
Assignee: Jan Lahoda
URL:
Keywords: REGRESSION
: 58475 (view as bug list)
Depends on:
Blocks: 55533
  Show dependency tree
 
Reported: 2005-04-30 09:22 UTC by tomsve
Modified: 2005-05-03 10:51 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Demo project structure (2.29 KB, application/x-compressed)
2005-05-01 10:01 UTC, tomsve
Details
Project structure demo (2.29 KB, application/x-compressed)
2005-05-01 10:08 UTC, tomsve
Details
Patch to fix this problem. (1.97 KB, patch)
2005-05-01 11:59 UTC, Jan Lahoda
Details | Diff
Binary patch for release 4.1. (277.22 KB, application/octet-stream)
2005-05-02 10:16 UTC, Jan Lahoda
Details
Java/freeform that should fix the second problem. (306.42 KB, application/octet-stream)
2005-05-02 11:10 UTC, Jan Lahoda
Details
Patch. (19.39 KB, patch)
2005-05-02 15:22 UTC, Jan Lahoda
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tomsve 2005-04-30 09:22:56 UTC
I have a very large software project that I have been developing with netbeans
since netbeans 3.x. This project contains a lot of subcomponents that as of
netbeans 4.0 needs to be their own netbeans projects, which is OK and quite
logical. The hirarchial structure of my project consists of a main catalog for
the project with common files. Under this there are subcatalogs for each
subcomponent, which as I said are the netbeans project catalogs of the
subcomponents. 

This structure worked fine in 4.0. It worked fine in most of the development
builds of 4.1. Creating a J2EE project for example creates a similar structure
with the web module and the ejb module projects under the J2EE project catalog.
But with 4.1rc1 this structure is no longer allowed! It is now impossible to
create a netbeans project (with existing ant script) that resides in a catalog
that is an undercatalog to another netbeans project! The "Finnish" button is
greyed out and a warning text informs that the selected catalog already belongs
to another project (my main "top level" project). 

4.1rc1 has no problem opening the old structure imported from 4.0 with all
subprojects being under the main project, but adding one more subproject is now
impossible. Since the type of the subproject I wanted to create was a simple
java project I could go back to 4.0 and create it, and then start 4.1rc1 again
and open that project without problems. It is only in the create project wizard
that this structure is stopped. 

I consider this a defect and a very serious one at that. If this is really a
feature I will go down on my knees and beg you to reconsider!!! This is a total
stopper, I cannot use 4.1rc1!
 
I'm an absolute and total fan of netbeans and have used it since before Sun
bought it! If I can no longer use netbeans for other than small simple
structured projects then netbeans have been totally destroyed in my point of
view, and I will seriously mourn it.
Comment 1 Jesse Glick 2005-04-30 19:25:59 UTC
If you want to help, please (1) calm down momentarily, (2) attach *complete and
unambiguous* steps to reproduce the problem you are having from scratch -
pristine IDE build, fresh user directory, and whatever data files / build
scripts / Java sources / etc. that are needed to reproduce attached to the bug
report, e.g. in a ZIP file, preferably in a minimal, stripped-down form. We need
to be able to go through your steps in order and confirm that they work
correctly in 4.1 beta (or 4.0 or something) and do not work in the 4.1 RC, and
then determine why this is. If we can get that far, fixing it is likely to be easy.

Also double-check your terminology and compare against the online help; for
example, I have no idea what you mean by "undercatalog". Refer to visible UI
elements ("Tools -> Java Platform Manager" etc.) for clarity. Do not say "create
a project"; *I* don't know what kind of project you created, or what parameters
you gave to it, and some of these details are probably critical. Specify which
menu item you selected, which nodes you selected, which buttons you pressed,
what text you typed in, what you saw happen at each stage. I know it's tedious
but it makes a big difference.

Note: we are very close to releasing 4.1 and only showstopper bugs can be fixed
now, so even a day's delay may be significant. Note 2: whatever the bug here is
(if it is a bug), I am sure there is some straightforward workaround you could
use even if 4.1 gets released without it. The project creation wizards just
create a few files on disk; there is nothing magical about it.
Comment 2 tomsve 2005-05-01 10:01:30 UTC
Created attachment 21925 [details]
Demo project  structure
Comment 3 tomsve 2005-05-01 10:07:00 UTC
I was first shocked and confused by your reply, but when reading my text again I
do sound quite upset, which I was not aware of myself. I did not feel upset and
I felt quite calm. Sorry. 

I have now attatched a zip file having the following content:

nb-bug-demo/
  build/
    build.xml
  src/
  nbproject/
    (netbeans proj files)
  components/
    comp1/
      build/
        build.xml
      src/

The bn-bug-demo catalog is a netbeans project with an existing Ant script. 

Now I want to add the comp1 catalog as another netbeans project with an existing
Ant script. 

I do:
- "File" menu -> "New Project ...".
  - Select "General" as "Category".
  - Select "Java project with existing Ant script".
  - Press "Next" button.
  - Select ".../nb-bug-demo/components/comp1" as "Location".
  - Select ".../nb-bug-demo/components/comp1/build/build.xml" as ant script.

The "Next" and "Finnish" buttons are now disabled, and a text in blue color
appears above the bottom buttons in the dialog. It says "Project folder is
already owned by Netbeans project nb-bug-demo".

That is what I meant by subcatalog. comp1 residens under nb-bug-demo which is a
netbeans project. In my other project which I mentioned I have a lot project
components that have their own ant scripts and own source catalogs and are their
own Netbeans projects but riside in the filesystem under the main project
catalog which is also a Netbeans project. 

This is a structure that Netbeans previously has had no problems with, and for
4.1rc1 it is only the create new project wizard that has the problem. If I go
back to 4.0 and create the project, and then go back to 4.1rc1 is has no problem
opening the project. The validation that the project catalog exists under
another project catalog in the new project wizard did however seem very
intentional, and not an accident, someone has put that validation there. That
did scare me, I must addmit. 

I hope this makes it much clearer, and in general thanks to all the Netbeans
developers for an in general excellent piece of software.

/Tommy
Comment 4 tomsve 2005-05-01 10:08:02 UTC
Created attachment 21926 [details]
Project structure demo
Comment 5 tomsve 2005-05-01 10:09:35 UTC
Oops! I though my first attachment failed, but apparently it didn't! So they are
identical.

/Tommy
Comment 6 Jan Lahoda 2005-05-01 11:24:23 UTC
I can reproduce the problem. It is obviously not possible to create a new
freeform project inside the directory hierarchy of some other existing project.
I have modified the summary accordingly.

In my opinion, this was caused by fix for issue #55533.
Comment 7 Jan Lahoda 2005-05-01 11:58:21 UTC
I am attaching patch (against trunk) that hopefully fixes both this issue and
issue #55533.
Comment 8 Jan Lahoda 2005-05-01 11:59:13 UTC
Created attachment 21927 [details]
Patch to fix this problem.
Comment 9 Jan Chalupa 2005-05-01 12:40:40 UTC
So can anyone confirm this is a regression in 4.1 RC as suggested by tomsve?
Comment 10 Jan Lahoda 2005-05-01 15:15:39 UTC
Fix for #55533 has been committed on 28 Feb 2005. I am able to create a freeform
project inside a J2SE project in 4.0, but I cannot in 4.1RC1.
Comment 11 Jesse Glick 2005-05-01 17:10:48 UTC
Re. patch:

1. if ((p=FileOwnerQuery.getOwner(projectFolder.toURI()))!=null && projectFolder
!= null ...

[BTW please put spaces around binary operators like = and !=]

If projectFolder == null, wouldn't the first part of the clause have already
thrown an NPE? So, no need to check for it. Put an

assert projectFolder != null

on the previous line if it should never be null (otherwise fix the if-statement
to be false in case it is null).

2. Such an important fix requires a unit test - for both the problem that issue
#55533 fixes (since Tomas did not write one at that time) and the regression its
attempted fix caused - so it never gets broken again.

Jan please attach some quick steps to reproduce for the benefit of QA. The fix
looks OK to me if it works. I agree it is P1 and a candidate for the 4.1 release
even at this late date. There should be a workaround - temporarily move the Ant
script to some temp folder, create a freeform project around, then move the
script and NB metadata back into its proper location - but this could be rather
cumbersome and this involves basic project setup functionality.
Comment 12 Jesse Glick 2005-05-01 17:26:11 UTC
Oops, please disregard my comment "Jan please attach some quick steps to
reproduce for the benefit of QA" - I somehow missed tomsve's steps to reproduce,
which should be all we need (thanks for such quick turnaround!).

The quick summary - originally, you were permitted to create a freeform project
with either the project directory, or the external project location (if
applicable), being identical to the project directory of another project (of
whatever type) - which was not good. The patch for issue #55533 fixed this, but
unintentionally also prevented you from creating a freeform project *in a
subdirectory of* another project, which is harmless and should be allowed.

Open question, a bit more obscure: say /src/something is an Ant project with a
build.xml etc., and the user creates a freeform project in /src/something-nb
with external project location /src/something (to keep /src/something free of
NB-specific metadata), fine. Now the user *again* goes and tries to make a
freeform project in /src/something-nb-2 with ext prj locn /src/something (for
whatever reason). What will happen? With issue #55533 fix, the wizard will
refuse, since /src/something is owned by /src/something-nb; after Jan's patch, I
guess the wizard will permit it, since /src/something is not a project
directory, at which point the two projects will conflict over /src/something...
one of them will "win" and be marked as the owner. This, however, is I think a
much less important problem (unlikely usage scenario); it could be fixed only
with an impl of issue #53369, so that the wizard the second time around would
know that /src/something was already explicitly owned by /src/something-nb.
Perhaps file this problem separately (dep on #53369) and fix for 4.2.
Comment 13 Jan Chalupa 2005-05-01 17:41:46 UTC
Milan, QA holds the keys now. We need a quick decision whether this can go into 4.1.

Jan, please put the fix into trunk and send a notice to reviewers@netbeans.org.
If QA is fine with it, the integration will have to go into release41 asap.
Comment 14 Jan Lahoda 2005-05-01 18:03:44 UTC
Re patch:
1. The check for null is really useless. Re formating: I simply reused part of
the original line without any big changes, incl. formatting. 
2. Ok, will do a test for it.

Quick steps to reproduce:
1. Create a new J2SE application "JavaApplication1" in directory ${TEST} (so
there is ${TEST}/JavaApplication1).
2. Create directory ${TEST}/JavaApplication1/FreeForm1 and put an ant script
into it.
3. Try to create a new freeform project with location
${TEST}/JavaApplication1/FreeForm1 - the wizard will not allow this.
Comment 15 Milan Kubec 2005-05-02 07:57:40 UTC
Please provide binary path against release41 branch. Thanks.
Comment 16 Milan Kubec 2005-05-02 08:42:44 UTC
Please provide also some info about what everything might be affected by this
change, whether this patch is involved only in this particular situation or is
involved in creating of any other project type. Thanks.
Comment 17 Jan Lahoda 2005-05-02 10:00:32 UTC
Re risks: the patch affects all "freeform" projects, ie. Java Freeform, Web
Freeform and EJB Freeform (and any other project type based on ant/freeform). It
affects only the "Name and Location" panel of the wizard.

Fixed in trunk. Diff:
http://ant.netbeans.org/source/browse/ant/freeform/src/org/netbeans/modules/ant/freeform/ui/BasicProjectInfoPanel.java?r1=1.19&r2=1.20

Commit message:
Checking in
freeform/src/org/netbeans/modules/ant/freeform/ui/BasicProjectInfoPanel.java;
/cvs/ant/freeform/src/org/netbeans/modules/ant/freeform/ui/BasicProjectInfoPanel.java,v
 <--  BasicProjectInfoPanel.java
new revision: 1.20; previous revision: 1.19
done
RCS file:
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/build.xml,v
done
Checking in freeform/test/unit/data/example-projects/freeforminside/build.xml;
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/build.xml,v 
<--  build.xml
initial revision: 1.1
done
RCS file:
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/FreeForm/build.xml,v
done
Checking in
freeform/test/unit/data/example-projects/freeforminside/FreeForm/build.xml;
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/FreeForm/build.xml,v
 <--  build.xml
initial revision: 1.1
done
RCS file:
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/FreeForm/src/javaapplication1/Main.java,v
done
Checking in
freeform/test/unit/data/example-projects/freeforminside/FreeForm/src/javaapplication1/Main.java;
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/FreeForm/src/javaapplication1/Main.java,v
 <--  Main.java
initial revision: 1.1
done
RCS file:
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/nbproject/project.xml,v
done
Checking in
freeform/test/unit/data/example-projects/freeforminside/nbproject/project.xml;
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/nbproject/project.xml,v
 <--  project.xml
initial revision: 1.1
done
RCS file:
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/src/javaapplication1/Main.java,v
done
Checking in
freeform/test/unit/data/example-projects/freeforminside/src/javaapplication1/Main.java;
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/src/javaapplication1/Main.java,v
 <--  Main.java
initial revision: 1.1
done
RCS file: /cvs/ant/freeform/test/unit/data/example-projects/simple3/build.xml,v
done
Checking in freeform/test/unit/data/example-projects/simple3/build.xml;
/cvs/ant/freeform/test/unit/data/example-projects/simple3/build.xml,v  <-- 
build.xml
initial revision: 1.1
done
RCS file:
/cvs/ant/freeform/test/unit/data/example-projects/simple3/src/javaapplication1/Main.java,v
done
Checking in
freeform/test/unit/data/example-projects/simple3/src/javaapplication1/Main.java;
/cvs/ant/freeform/test/unit/data/example-projects/simple3/src/javaapplication1/Main.java,v
 <--  Main.java
initial revision: 1.1
done
RCS file:
/cvs/ant/freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/BasicProjectInfoPanelTest.java,v
done
Checking in
freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/BasicProjectInfoPanelTest.java;
/cvs/ant/freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/BasicProjectInfoPanelTest.java,v
 <--  BasicProjectInfoPanelTest.java
initial revision: 1.1
done
Comment 18 Jan Lahoda 2005-05-02 10:14:50 UTC
Attaching binary patch org-netbeans-modules-ant-freeform.jar, place it into
${NETBEANS_INSTALL}/ide5/modules, replacing old file.
Comment 19 Jan Lahoda 2005-05-02 10:16:19 UTC
Created attachment 21930 [details]
Binary patch for release 4.1.
Comment 20 Milan Kubec 2005-05-02 10:36:44 UTC
The fix is only partial - other check whether sources aren't part of existing
project is done on panel where user adds source roots to the project. And by the
time of creating the project those source roots still belongs to the
superproject and user cannot add such source roots.

Workaround is *not to add* those source roots during creating freeform project
but after the project is created from project properties, but I doubt anybody
would guess that.

Is this fixable?
Comment 21 Tomas Zezula 2005-05-02 10:52:56 UTC
Yes, it is fixable. The wizard will need to extend the check when adding the
source roots to check if the new source root is under projectLocation folder.

if (FileOwnerQuery.getOwner (sourceRoot) != null && !FileUtil.isParentOf
(projectLocation,srcRoot)) {
  //Show warning
}
Comment 22 Milan Kubec 2005-05-02 10:59:33 UTC
Please provide binary patch for the fix. Is this fix only in the java freeform
wizard or is it part of Java Freeform Project Properties?
Comment 23 Jan Lahoda 2005-05-02 11:08:40 UTC
Re the second problem: it is in java/freeform. Affects both new Java freeform
and Java freeform's project properties. IMO also affects all project types that
use the Java Nature (Web+EJB).
Comment 24 Jan Lahoda 2005-05-02 11:10:08 UTC
Created attachment 21931 [details]
Java/freeform that should fix the second problem.
Comment 25 Petr Blaha 2005-05-02 11:27:14 UTC
*** Issue 58475 has been marked as a duplicate of this issue. ***
Comment 26 Milan Kubec 2005-05-02 14:32:27 UTC
Please, would you provide diff for the second fix.
Comment 27 Jan Lahoda 2005-05-02 15:20:40 UTC
Please, file a new bug against java/freeform for the second problem.

The proposed fix for this bug (cannot create a new freeform project inside
directory hierarchy of another project) for release 4.1 is:
http://ant.netbeans.org/source/browse/ant/freeform/src/org/netbeans/modules/ant/freeform/ui/BasicProjectInfoPanel.java?r1=1.19&r2=1.20

I will also attach complete patchset (including tests) for this problem.

Tomas, Jesse could you please review the fix?
Comment 28 Jan Lahoda 2005-05-02 15:22:14 UTC
Created attachment 21936 [details]
Patch.
Comment 29 Milan Kubec 2005-05-02 15:28:38 UTC
Second problem is filed as #58490.
Comment 30 Jesse Glick 2005-05-02 20:23:10 UTC
Last patch looks OK to me.
Comment 31 Milan Kubec 2005-05-03 09:15:15 UTC
Tested and verified using provided binary patch against release41 RC2 build.
Comment 32 Tomas Zezula 2005-05-03 10:22:06 UTC
The attached patch is good.
Comment 33 Jan Lahoda 2005-05-03 10:51:59 UTC
Committed to release 4.1:
Checking in
freeform/src/org/netbeans/modules/ant/freeform/ui/BasicProjectInfoPanel.java;
/cvs/ant/freeform/src/org/netbeans/modules/ant/freeform/ui/BasicProjectInfoPanel.java,v
 <--  BasicProjectInfoPanel.java
new revision: 1.19.6.1; previous revision: 1.19
done
Checking in freeform/test/unit/data/example-projects/freeforminside/build.xml;
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/build.xml,v 
<--  build.xml
new revision: 1.1.2.1; previous revision: 1.1
done
Checking in
freeform/test/unit/data/example-projects/freeforminside/FreeForm/build.xml;
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/FreeForm/build.xml,v
 <--  build.xml
new revision: 1.1.2.1; previous revision: 1.1
done
Checking in
freeform/test/unit/data/example-projects/freeforminside/FreeForm/src/javaapplication1/Main.java;
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/FreeForm/src/javaapplication1/Main.java,v
 <--  Main.java
new revision: 1.1.2.1; previous revision: 1.1
done
Checking in
freeform/test/unit/data/example-projects/freeforminside/nbproject/project.xml;
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/nbproject/project.xml,v
 <--  project.xml
new revision: 1.1.2.1; previous revision: 1.1
done
Checking in
freeform/test/unit/data/example-projects/freeforminside/src/javaapplication1/Main.java;
/cvs/ant/freeform/test/unit/data/example-projects/freeforminside/src/javaapplication1/Main.java,v
 <--  Main.java
new revision: 1.1.2.1; previous revision: 1.1
done
Checking in freeform/test/unit/data/example-projects/simple3/build.xml;
/cvs/ant/freeform/test/unit/data/example-projects/simple3/build.xml,v  <-- 
build.xml
new revision: 1.1.2.1; previous revision: 1.1
done
Checking in
freeform/test/unit/data/example-projects/simple3/src/javaapplication1/Main.java;
/cvs/ant/freeform/test/unit/data/example-projects/simple3/src/javaapplication1/Main.java,v
 <--  Main.java
new revision: 1.1.2.1; previous revision: 1.1
done
Checking in
freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/BasicProjectInfoPanelTest.java;
/cvs/ant/freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/BasicProjectInfoPanelTest.java,v
 <--  BasicProjectInfoPanelTest.java
new revision: 1.1.2.1; previous revision: 1.1
done