### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/builder/BatchImageBuilder.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/BatchImageBuilder.java,v retrieving revision 1.66 diff -u -r1.66 BatchImageBuilder.java --- model/org/eclipse/jdt/internal/core/builder/BatchImageBuilder.java 22 Dec 2006 16:02:08 -0000 1.66 +++ model/org/eclipse/jdt/internal/core/builder/BatchImageBuilder.java 5 Jan 2007 16:52:30 -0000 @@ -131,13 +131,15 @@ if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) { IResource resource = proxy.requestResource(); if (exclusionPatterns != null || inclusionPatterns != null) - if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false; + if (Util.isExcluded(resource.getFullPath(), inclusionPatterns, exclusionPatterns, false)) + return false; resource.delete(IResource.FORCE, null); } return false; } if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null - if (Util.isExcluded(proxy.requestResource(), inclusionPatterns, exclusionPatterns)) return false; + if (Util.isExcluded(proxy.requestFullPath(), null, exclusionPatterns, true)) + return false; notifier.checkCancel(); return true; } @@ -193,7 +195,7 @@ resource = proxy.requestResource(); if (javaBuilder.filterExtraResource(resource)) return false; if (exclusionPatterns != null || inclusionPatterns != null) - if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) + if (Util.isExcluded(resource.getFullPath(), inclusionPatterns, exclusionPatterns, false)) return false; IPath partialPath = resource.getFullPath().removeFirstSegments(segmentCount); @@ -220,7 +222,8 @@ if (javaBuilder.filterExtraResource(resource)) return false; if (isAlsoProject && isExcludedFromProject(resource.getFullPath())) return false; // the sourceFolder == project if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null - if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false; + if (Util.isExcluded(resource.getFullPath(), null, exclusionPatterns, true)) + return false; } return true; } Index: model/org/eclipse/jdt/internal/core/builder/IncrementalImageBuilder.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/IncrementalImageBuilder.java,v retrieving revision 1.90 diff -u -r1.90 IncrementalImageBuilder.java --- model/org/eclipse/jdt/internal/core/builder/IncrementalImageBuilder.java 22 Dec 2006 16:02:08 -0000 1.90 +++ model/org/eclipse/jdt/internal/core/builder/IncrementalImageBuilder.java 5 Jan 2007 16:52:30 -0000 @@ -431,6 +431,18 @@ ArrayList visited = this.makeOutputFolderConsistent ? new ArrayList(sourceLocations.length) : null; for (int i = 0, l = sourceLocations.length; i < l; i++) { ClasspathMultiDirectory md = sourceLocations[i]; + if (this.makeOutputFolderConsistent && md.hasIndependentOutputFolder && !visited.contains(md.binaryFolder)) { + // even a project which acts as its own source folder can have an independent/nested output folder + visited.add(md.binaryFolder); + IResourceDelta binaryDelta = delta.findMember(md.binaryFolder.getProjectRelativePath()); + if (binaryDelta != null) { + int segmentCount = binaryDelta.getFullPath().segmentCount(); + IResourceDelta[] children = binaryDelta.getAffectedChildren(); + for (int j = 0, m = children.length; j < m; j++) + if (!checkForClassFileChanges(children[j], md, segmentCount)) + return false; + } + } if (md.sourceFolder.equals(javaBuilder.currentProject)) { // skip nested source & output folders when the project is a source folder int segmentCount = delta.getFullPath().segmentCount(); @@ -440,17 +452,6 @@ if (!findSourceFiles(children[j], md, segmentCount)) return false; } else { - if (this.makeOutputFolderConsistent && md.hasIndependentOutputFolder && !visited.contains(md.binaryFolder)) { - visited.add(md.binaryFolder); - IResourceDelta binaryDelta = delta.findMember(md.binaryFolder.getProjectRelativePath()); - if (binaryDelta != null) { - int segmentCount = binaryDelta.getFullPath().segmentCount(); - IResourceDelta[] children = binaryDelta.getAffectedChildren(); - for (int j = 0, m = children.length; j < m; j++) - if (!checkForClassFileChanges(children[j], md, segmentCount)) - return false; - } - } IResourceDelta sourceDelta = delta.findMember(md.sourceFolder.getProjectRelativePath()); if (sourceDelta != null) { if (sourceDelta.getKind() == IResourceDelta.REMOVED) { Index: model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java,v retrieving revision 1.101 diff -u -r1.101 AbstractImageBuilder.java --- model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java 22 Dec 2006 16:02:08 -0000 1.101 +++ model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java 5 Jan 2007 16:52:30 -0000 @@ -219,16 +219,25 @@ if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) { IResource resource = proxy.requestResource(); if (exclusionPatterns != null || inclusionPatterns != null) - if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false; + if (Util.isExcluded(resource.getFullPath(), inclusionPatterns, exclusionPatterns, false)) + return false; sourceFiles.add(new SourceFile((IFile) resource, sourceLocation)); } return false; case IResource.FOLDER : - if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null - if (Util.isExcluded(proxy.requestResource(), inclusionPatterns, exclusionPatterns)) return false; IPath folderPath = null; if (isAlsoProject) - if (isExcludedFromProject(folderPath = proxy.requestFullPath())) return false; + if (isExcludedFromProject(folderPath = proxy.requestFullPath())) + return false; + if (exclusionPatterns != null) { + if (folderPath == null) + folderPath = proxy.requestFullPath(); + if (Util.isExcluded(folderPath, inclusionPatterns, exclusionPatterns, true)) { + // must walk children if inclusionPatterns != null, can skip them if == null + // but folder is excluded so do not create it in the output folder + return inclusionPatterns != null; + } + } if (!isOutputFolder) { if (folderPath == null) folderPath = proxy.requestFullPath(); #P org.eclipse.jdt.core.tests.builder Index: src/org/eclipse/jdt/core/tests/builder/CopyResourceTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/CopyResourceTests.java,v retrieving revision 1.19 diff -u -r1.19 CopyResourceTests.java --- src/org/eclipse/jdt/core/tests/builder/CopyResourceTests.java 28 Jun 2006 19:38:47 -0000 1.19 +++ src/org/eclipse/jdt/core/tests/builder/CopyResourceTests.java 5 Jan 2007 16:52:32 -0000 @@ -31,33 +31,57 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=117302 public void testFilteredResources() throws JavaModelException { IPath projectPath = env.addProject("P"); //$NON-NLS-1$ - IPath src = env.getPackageFragmentRootPath(projectPath, ""); //$NON-NLS-1$ - env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$ + env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$ + IPath src = env.addPackageFragmentRoot( + projectPath, + "", //$NON-NLS-1$ + new IPath[] {new org.eclipse.core.runtime.Path("foo/;bar/")}, //$NON-NLS-1$ + new IPath[] {new org.eclipse.core.runtime.Path("foo/ignored/")}, //$NON-NLS-1$ + "bin"); //$NON-NLS-1$ env.addExternalJars(projectPath, Util.getJavaClassLibs()); - env.addClass(src, "x", "A", //$NON-NLS-1$ //$NON-NLS-2$ - "package x;"+ //$NON-NLS-1$ - "public class A extends q.B {}" //$NON-NLS-1$ + env.addClass(src, "foo", "A", //$NON-NLS-1$ //$NON-NLS-2$ + "package foo;"+ //$NON-NLS-1$ + "public class A extends bar.B {}" //$NON-NLS-1$ ); - env.addClass(src, "q", "B", //$NON-NLS-1$ //$NON-NLS-2$ - "package q;"+ //$NON-NLS-1$ + env.addClass(src, "bar", "B", //$NON-NLS-1$ //$NON-NLS-2$ + "package bar;"+ //$NON-NLS-1$ "public class B {}" //$NON-NLS-1$ ); - env.addFile(src.append("q"), "test.txt", "test file"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + env.addFolder(src, "foo/skip"); //$NON-NLS-1$ + IPath ignored = env.addFolder(src, "foo/ignored"); //$NON-NLS-1$ + env.addFile(ignored, "test.txt", "test file"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + env.addFile(src.append("bar"), "test.txt", "test file"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + org.eclipse.jdt.core.IJavaProject p = env.getJavaProject("P"); java.util.Map options = p.getOptions(true); - options.put(org.eclipse.jdt.core.JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, "q*"); //$NON-NLS-1$ + options.put(org.eclipse.jdt.core.JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, "bar*"); //$NON-NLS-1$ + options.put(org.eclipse.jdt.core.JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, "enabled"); //$NON-NLS-1$ p.setOptions(options); int max = org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE; try { org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE = 1; fullBuild(); + expectingNoProblems(); + expectingNoPresenceOf(projectPath.append("bin/foo/skip/")); //$NON-NLS-1$ + expectingNoPresenceOf(projectPath.append("bin/foo/ignored/")); //$NON-NLS-1$ + expectingNoPresenceOf(projectPath.append("bin/bar/test.txt")); //$NON-NLS-1$ + + env.removeFolder(projectPath.append("bin/bar")); //$NON-NLS-1$ + env.addClass(src, "x", "A", //$NON-NLS-1$ //$NON-NLS-2$ + "package x;"+ //$NON-NLS-1$ + "public class A extends bar.B {}" //$NON-NLS-1$ + ); + env.addFile(src.append("bar"), "test.txt", "changed test file"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + incrementalBuild(); + expectingNoProblems(); + expectingNoPresenceOf(projectPath.append("bin/foo/skip/")); //$NON-NLS-1$ + expectingNoPresenceOf(projectPath.append("bin/foo/ignored/")); //$NON-NLS-1$ + expectingNoPresenceOf(projectPath.append("bin/bar/test.txt")); //$NON-NLS-1$ } finally { org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE = max; } - expectingNoProblems(); - expectingNoPresenceOf(projectPath.append("bin/q/test.txt")); //$NON-NLS-1$ } public void testSimpleProject() throws JavaModelException { Index: src/org/eclipse/jdt/core/tests/builder/MultiSourceFolderAndOutputFolderTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/MultiSourceFolderAndOutputFolderTests.java,v retrieving revision 1.17 diff -u -r1.17 MultiSourceFolderAndOutputFolderTests.java --- src/org/eclipse/jdt/core/tests/builder/MultiSourceFolderAndOutputFolderTests.java 29 Mar 2006 03:16:23 -0000 1.17 +++ src/org/eclipse/jdt/core/tests/builder/MultiSourceFolderAndOutputFolderTests.java 5 Jan 2007 16:52:32 -0000 @@ -289,7 +289,7 @@ public void test0012() throws JavaModelException { IPath projectPath = env.addProject("P"); env.removePackageFragmentRoot(projectPath, ""); - IPath src = env.addPackageFragmentRoot(projectPath, "", new IPath[] {new Path("p1/p2/p3/X.java"), new Path("Y.java")}, false/*inclusion*/, ""); + IPath src = env.addPackageFragmentRoot(projectPath, "", new IPath[] {new Path("p1/p2/p3/X.java"), new Path("Y.java")}, null, ""); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.addClass(src, "p1.p2.p3", "X", Index: src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java,v retrieving revision 1.49 diff -u -r1.49 TestingEnvironment.java --- src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java 20 Dec 2006 16:11:41 -0000 1.49 +++ src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java 5 Jan 2007 16:52:32 -0000 @@ -142,7 +142,7 @@ * Returns the path of the added package fragment root. */ public IPath addPackageFragmentRoot(IPath projectPath, String sourceFolderName, IPath[] exclusionPatterns, String specificOutputLocation) throws JavaModelException { - return addPackageFragmentRoot(projectPath, sourceFolderName, exclusionPatterns, true/*exclusion patterns*/, specificOutputLocation); + return addPackageFragmentRoot(projectPath, sourceFolderName, null, exclusionPatterns, specificOutputLocation); } /** Adds a package fragment root to the workspace. If @@ -150,7 +150,7 @@ * exists, it is not replaced. A workspace must be open. * Returns the path of the added package fragment root. */ - public IPath addPackageFragmentRoot(IPath projectPath, String sourceFolderName, IPath[] patterns, boolean areExclusionPatterns, String specificOutputLocation) throws JavaModelException { + public IPath addPackageFragmentRoot(IPath projectPath, String sourceFolderName, IPath[] inclusionPatterns, IPath[] exclusionPatterns, String specificOutputLocation) throws JavaModelException { checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$ IPath path = getPackageFragmentRootPath(projectPath, sourceFolderName); createFolder(path); @@ -159,13 +159,11 @@ outputPath = getPackageFragmentRootPath(projectPath, specificOutputLocation); createFolder(outputPath); } - IClasspathEntry entry; - if (areExclusionPatterns) - // exclusion patterns - entry = JavaCore.newSourceEntry(path, patterns == null ? new Path[0] : patterns, outputPath); - else - // inclusion patterns - entry = JavaCore.newSourceEntry(path, patterns == null ? new Path[0] : patterns, new Path[0], outputPath); + IClasspathEntry entry = JavaCore.newSourceEntry( + path, + inclusionPatterns == null ? new Path[0] : inclusionPatterns, + exclusionPatterns == null ? new Path[0] : exclusionPatterns, + outputPath); addEntry(projectPath, entry); return path; }