Community
Participate
Working Groups
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
Maxime - do we also have same issue in batch compiler ?
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.
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.
Bug is present in 3.2.1, cloned as Bug #165446
*** Bug 165446 has been marked as a duplicate of this bug. ***
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)
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).
Appears to be caused by the fix for bug 117302
Conny : should the exclusion pattern in your example be "foo/ignored/" instead of "foo/ignored" ?
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.
Created attachment 56469 [details] Patch for 3.2.x stream
Released for 3.3 M5 in HEAD stream Released for 3.2.2 in R3_2_maintenance stream
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.
@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).
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?
Verified for 3.2.2 using build M20070112-1200.
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.
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/**.
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.
(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.