Bug 157336 - build output contains unnecessary empty directories
Summary: build output contains unnecessary empty directories
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.1   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: 3.2.2   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 165446 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-09-14 11:31 EDT by Howard CLA
Modified: 2007-02-05 13:54 EST (History)
2 users (show)

See Also:


Attachments
Current version of the patch against HEAD (14.90 KB, patch)
2007-01-05 12:01 EST, Kent Johnson CLA
no flags Details | Diff
Patch for 3.2.x stream (12.43 KB, patch)
2007-01-05 12:14 EST, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Howard CLA 2006-09-14 11:31:19 EDT
Build output contains unnecessary empty directories

1. Create new Java project
2. Create linked source dir that contains many directories (e.g., foo, bar)
3. Add "foo/**/*.java" filter to source dir
4. Build project
5. Destination output directory contains empty directory bar
Comment 1 Philipe Mulet CLA 2006-09-15 03:58:26 EDT
Maxime - do we also have same issue in batch compiler ?
Comment 2 Howard CLA 2006-09-20 11:54:08 EDT
The problem also occurs if the directory is *not* empty but should be filtered out.

i.e., If I add the directory to
    Preferences -> Java -> Compiler -> Building
    Field "Filtered Resources"
that directory [and its subdirectories] is still created in the output directory

As a side note: I have noticed that if the directories contain *many* files/subdirs, but only a handful of which I want to compile, Eclipse takes a while to rebuild the project ... despite my best efforts in crafting a tight inclusion filter.
Comment 3 Howard CLA 2006-09-20 12:28:59 EDT
I realized my mistake.  I was using a preview of 3.2.1 JDT (from http://www.eclipse.org/jdt/core/r3.2/index.php#UPDATES) because I needed the fix for bug 149028.

Official 3.2 release does *not* have this bug.  I hope that final 3.2.1 release will not introduce this bug however.

Apologies for the misreporting.
Comment 4 Martin Cornelius CLA 2006-11-22 09:21:32 EST
Bug is present in 3.2.1, cloned as Bug #165446
Comment 5 Frederic Fusier CLA 2006-11-22 09:36:26 EST
*** Bug 165446 has been marked as a duplicate of this bug. ***
Comment 6 Frederic Fusier CLA 2006-11-22 09:37:34 EST
Copy of bug 165446 comment 0:

The bug described in #157336 IS present in Release 3.2.1. If the output folder
is a descendant of the project root folder, the COMPLETE folder hierarchy (only
folders, not files) below the root folder is replicated to the output folder,
regardless if the (filtered) content of a folder is empty or not.

Even worse: As the output folder itself is a part of this hierarchy, the
replicated hierarchy (below the output folder) is once again replicated to the
replicated copy of the output folder. Luckily, this recursive replicating seems
to happen only once, (otherwise eclipse would continue replicating until the
disk was filled with empty folders)

Comment 7 Conny Krappatsch CLA 2006-11-23 03:44:55 EST
Using Windows XP, Sun jdk 1.4.2_13, Eclipse 3.2.1
How to reproduce:

- create a new Java project (using name "emptyFolders"; default settings)
["Project > Build automatically" is activated]
- create the packages foo.bar and foo.ignored
  directory structure (as seen in Navigator):
    emptyFolders
        foo
            bar
            ignored

- in "Project > Properties > Java Build Path > Source" change "Default output folder" to "emtpyFolders/eclipse-build"
  directory structure (only the folders):
    emptyFolders
        eclipse-build
            foo
                bar
                ignored
        foo
            bar
            ignored

- in "Project > Properties > Java Build Path > Source" set "Included" pattern of "emptyFolders" to "foo/"
[eclipse specific files disapear from eclipse-build directory (as expected)]

- in "Project > Properties > Java Build Path > Source" set "Excluded" pattern of "emptyFolders" to "foo/ignored"
- nothing changes, i.e. "foo/ignored" is still present in "eclipse-build"

and another one:
- create a new directory "lib" in the root of the project
- clean the project ("Project > Clean...")
- the project is automatically rebuild and the "eclipse-build" contains the newly created "lib" directory (though we only included "foo/" into the source path)

Unfortunately, I wasn't able to create an easy example of the recursive replication but we definitely have it in our project (luckily not an infinite recursion).
Comment 8 Kent Johnson CLA 2007-01-03 14:35:48 EST
Appears to be caused by the fix for bug 117302
Comment 9 Kent Johnson CLA 2007-01-03 16:55:26 EST
Conny : should the exclusion pattern in your example be "foo/ignored/" instead of "foo/ignored" ?
Comment 10 Kent Johnson CLA 2007-01-05 12:01:55 EST
Created attachment 56468 [details]
Current version of the patch against HEAD

This bug was introduced in 3.2.1 as a result of the fix for bug 117302.
Comment 11 Kent Johnson CLA 2007-01-05 12:14:39 EST
Created attachment 56469 [details]
Patch for 3.2.x stream
Comment 12 Kent Johnson CLA 2007-01-05 12:39:12 EST
Released for 3.3 M5 in HEAD stream

Released for 3.2.2 in R3_2_maintenance stream
Comment 13 Howard CLA 2007-01-05 17:29:13 EST
Just tried org.eclipse.jdt.core_3.2.2.jar

Problem has been mostly fixed, but if I don't use *any* exclusion filter [but just a single inclusion filter] ... still too many directories are created.  Is this expected behavior?  Creating a dummy exclusion filter (e.g., "**/c/") seems to make the problem go away.
Comment 14 Conny Krappatsch CLA 2007-01-08 02:13:22 EST
@Kent (comment 9): The intention was to exclude the whole directory (not only its contents). According to Ant file pattern docu "foo/bar/" is treated as "foo/bar/**". So, as I understand it foo/bar/** should exclude the content of the directory and foo/bar should additionally exclude the directory itself. But I may be wrong (or too nitpicking).
Comment 15 Kent Johnson CLA 2007-01-08 12:20:48 EST
Re comment #13, everything is included by default.

So what are you trying to do by only specifying an inclusion pattern without an enclosing exclusion pattern?
Comment 16 Frederic Fusier CLA 2007-01-16 03:52:44 EST
Verified for 3.2.2 using build M20070112-1200.
Comment 17 Howard CLA 2007-01-16 13:07:17 EST
Re comment #15

In my particular case, the use of an exclusion filter is a bit contrived.  I'd appreciate a more intuitive workflow by Eclipse.

I have a directory mapped as a linked resource.  There are hundreds (if not thousands) of .java files in it.  I only want my project to compile a select few of these files (say 10 of them).  It's quite natural to use an inclusion filter to select those 10 files ... all of which are nested very deeply in directory hierarchy (i.e., have very long package names).

If I don't use an exclusion filter, I suppose the default exclusion filter you mentioned will cause Eclipse to scan many top level directories [and their children] that I don't care much for.  Unfortunately for me, this is a very expensive process as I have a *lot* of these directories.

If I use an exclusion filter, I need to come up w/ some contrived example such as "**/nosuchfile.txt".

I appreciate any suggestion you may have.  Thanks.
Comment 18 Conny Krappatsch CLA 2007-01-17 05:24:28 EST
Re comment #15

Just to give another example:

In our project we have a source folder with many different directories. One of them (directory "de") contains Java sources (the others don't).

This is from the eclipse docu about "Exclusion and inclusion filters": "The Java builder will ignore source files that are excluded, and the ones that are not included."

So it seems reasonable to just provide the inclusion pattern "de/**.
Comment 19 Kent Johnson CLA 2007-02-05 13:38:38 EST
Re: comment 18 "In our project we have a source folder with many different directories. One of them (directory "de") contains Java sources (the others don't)."

So why isn't the directory "de" setup as the source folder? Why choose its parent's directory if its the only folder with source files?

Re: comment 17, your example is needless to say extreme.

Almost all users do not exclude any source files from their source folders and it seems pointless to make them include them, since they expect them to be included by default.

If you want to setup a project as you describe, then you'll need to define an exclusion pattern that excludes ALL source files and explicitly include the 10 that you want.
Comment 20 Olivier Thomann CLA 2007-02-05 13:54:37 EST
(In reply to comment #7)
> - in "Project > Properties > Java Build Path > Source" set "Excluded" pattern
> of "emptyFolders" to "foo/ignored"
> - nothing changes, i.e. "foo/ignored" is still present in "eclipse-build"
This doesn't happen if the exclusion filter is "foo/ignored/".
 
> and another one:
> - create a new directory "lib" in the root of the project
> - clean the project ("Project > Clean...")
> - the project is automatically rebuild and the "eclipse-build" contains the
> newly created "lib" directory (though we only included "foo/" into the source
> path)
Doesn't happen anymore.

Closing as VERIFIED for 3.3M5 with I20070205-0009.