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 97168

Summary: "Multiple projects per root" use case is broken
Product: java Reporter: kirillkh <kirillkh>
Component: ProjectAssignee: Jesse Glick <jglick>
Status: RESOLVED WORKSFORME    
Severity: blocker    
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 98270    
Bug Blocks: 49026    
Attachments: watches2
Toy sample of two projects sharing a root, with one common package

Description kirillkh 2007-03-04 12:28:16 UTC
I have attempted to utilize the use case described at
http://wiki.netbeans.org/wiki/view/Excludes49026#section-Excludes49026-MultipleProjectsPerRoot

"Multiple projects per root

Untested: A source tree may be split among multiple projects so long as all of
them share the same classpath settings (and other similar queries such as source
level and output dir). Only files included in the union of open projects are
scanned."

I created a new project with existing sources, pointed it to a source directory
and specified an include filter for some files from there. Then I attempted to
create another project with existing sources and point it to the same source
directory in hope it would allow me to include the rest of the files. However,
on attempt to choose the source root I got an error dialog with message

"Package Folder Already Used in Project
Following folders you selected are already used in this or another project. One
package folder can only be used in one project in one package folder list
(source packages or test packages).

Package folders already in use:

C:\projects\app3\src\java (owned by app3)"
Comment 1 Tomas Zezula 2007-03-06 13:21:49 UTC
Not sure if we should support it. Reassigning to Jesse.
Comment 2 Jesse Glick 2007-03-06 15:47:49 UTC
I will try to enable the wizard to permit this, so long as the state after the
wizard is run proves to be usable. But it is not a principal use case.
Comment 3 kirillkh 2007-03-06 22:08:26 UTC
Thanks, Jesse. Includes/excludes is a cool feature even without the possibility
to have several projects per source root, but having it would definitely make my
life easier. My use case is one big source tree with most of the sources
comprising a web application, another large part - a client application
(considerable part of classes is shared with the web app), and in addition there
are several smaller executable applications (utilities). Would be great, if I
could separate all this mess into nice isolated projects.

BTW, currently there's no support for includes/excludes in web projects, should
I file another bug on that?
Comment 4 Jesse Glick 2007-03-07 02:00:43 UTC
An update: today I have been testing nonoverlapping projects pointing into the
same (external) source root and so far it seems to work fine. I had the project
metadata (project.xml etc.) set up by hand - currently the wizard will not let
you do it. You could set it up in the GUI if you closed one project (and maybe
restarted the IDE) before making the next one, I think, but it is cumbersome.
Please note that all the projects must use the same classpath settings or
behavior may be erratic (this is not yet detected as an error condition).

For incl/excl support in web projects, by all means file a FEATURE request, as I
don't think there is anything filed yet. Just make it block #49026 for tracking
purposes and put me on CC.
Comment 5 kirillkh 2007-04-01 13:11:03 UTC
Created attachment 40238 [details]
watches2
Comment 6 kirillkh 2007-04-01 13:11:59 UTC
Sorry, attached to the wrong issue :)
Comment 7 Jesse Glick 2007-10-22 17:37:29 UTC
*** Issue 119578 has been marked as a duplicate of this issue. ***
Comment 8 Jesse Glick 2007-10-26 21:57:51 UTC
Created attachment 51818 [details]
Toy sample of two projects sharing a root, with one common package
Comment 9 Jesse Glick 2007-10-26 22:24:24 UTC
I did not get such an error when I set up such a project pair in 071026 - I think because I used specific includes such
as "a/ b/" rather than including everything by default and excluding some things, meaning the source root dir itself is
not considered owned by any project (assuming you use separate project directories none of which are a parent of the
source directory). Even if you do run into this error, it should suffice to close the first project and restart the IDE
before creating the second project (after that you can reopen the first one if you want). Some caveats:

1. If you are sharing some common packages, they will be reported as owned by one of the projects arbitrarily, depending
on what projects have been opened and in what order. So e.g. F9 will build to the owner project's dir. If you want to
compile to another project's output directory it is best to run Build from that project's context menu.

2. All the projects must share the same classpath or behavior may be erratic.

3. If there is no defined owner for the source root (as in the attached example), the IDE will quietly assume a
classpath which is a merge of those of all _opened_ projects, which is not as precise as in the usual case. (Could
include more or fewer entries than it ought to.) Assuming you have the project you are working on open, you will
probably be OK; Ant compilation will catch any mistakes. If this becomes a problem, a workaround is to pick one or more
of the projects and set its includes to "**" and excludes to whatever is needed to give it the desired contents.

Sharing a source root across projects should not be considered fully supported, but it may work to a limited extent in
NB 6 if you follow these guidelines.