View | Details | Raw Unified | Return to bug 157336 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/builder/BatchImageBuilder.java (-4 / +7 lines)
Lines 131-143 Link Here
131
								if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
131
								if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
132
									IResource resource = proxy.requestResource();
132
									IResource resource = proxy.requestResource();
133
									if (exclusionPatterns != null || inclusionPatterns != null)
133
									if (exclusionPatterns != null || inclusionPatterns != null)
134
										if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false;
134
										if (Util.isExcluded(resource.getFullPath(), inclusionPatterns, exclusionPatterns, false))
135
											return false;
135
									resource.delete(IResource.FORCE, null);
136
									resource.delete(IResource.FORCE, null);
136
								}
137
								}
137
								return false;
138
								return false;
138
							}
139
							}
139
							if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null
140
							if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null
140
								if (Util.isExcluded(proxy.requestResource(), inclusionPatterns, exclusionPatterns)) return false;
141
								if (Util.isExcluded(proxy.requestFullPath(), null, exclusionPatterns, true))
142
									return false;
141
							notifier.checkCancel();
143
							notifier.checkCancel();
142
							return true;
144
							return true;
143
						}
145
						}
Lines 193-199 Link Here
193
						resource = proxy.requestResource();
195
						resource = proxy.requestResource();
194
						if (javaBuilder.filterExtraResource(resource)) return false;
196
						if (javaBuilder.filterExtraResource(resource)) return false;
195
						if (exclusionPatterns != null || inclusionPatterns != null)
197
						if (exclusionPatterns != null || inclusionPatterns != null)
196
							if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns))
198
							if (Util.isExcluded(resource.getFullPath(), inclusionPatterns, exclusionPatterns, false))
197
								return false;
199
								return false;
198
200
199
						IPath partialPath = resource.getFullPath().removeFirstSegments(segmentCount);
201
						IPath partialPath = resource.getFullPath().removeFirstSegments(segmentCount);
Lines 220-226 Link Here
220
						if (javaBuilder.filterExtraResource(resource)) return false;
222
						if (javaBuilder.filterExtraResource(resource)) return false;
221
						if (isAlsoProject && isExcludedFromProject(resource.getFullPath())) return false; // the sourceFolder == project
223
						if (isAlsoProject && isExcludedFromProject(resource.getFullPath())) return false; // the sourceFolder == project
222
						if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null
224
						if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null
223
							if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false;
225
							if (Util.isExcluded(resource.getFullPath(), null, exclusionPatterns, true))
226
								return false;
224
				}
227
				}
225
				return true;
228
				return true;
226
			}
229
			}
(-)model/org/eclipse/jdt/internal/core/builder/IncrementalImageBuilder.java (-11 / +12 lines)
Lines 431-436 Link Here
431
	ArrayList visited = this.makeOutputFolderConsistent ? new ArrayList(sourceLocations.length) : null;
431
	ArrayList visited = this.makeOutputFolderConsistent ? new ArrayList(sourceLocations.length) : null;
432
	for (int i = 0, l = sourceLocations.length; i < l; i++) {
432
	for (int i = 0, l = sourceLocations.length; i < l; i++) {
433
		ClasspathMultiDirectory md = sourceLocations[i];
433
		ClasspathMultiDirectory md = sourceLocations[i];
434
		if (this.makeOutputFolderConsistent && md.hasIndependentOutputFolder && !visited.contains(md.binaryFolder)) {
435
			// even a project which acts as its own source folder can have an independent/nested output folder
436
			visited.add(md.binaryFolder);
437
			IResourceDelta binaryDelta = delta.findMember(md.binaryFolder.getProjectRelativePath());
438
			if (binaryDelta != null) {
439
				int segmentCount = binaryDelta.getFullPath().segmentCount();
440
				IResourceDelta[] children = binaryDelta.getAffectedChildren();
441
				for (int j = 0, m = children.length; j < m; j++)
442
					if (!checkForClassFileChanges(children[j], md, segmentCount))
443
						return false;
444
			}
445
		}
434
		if (md.sourceFolder.equals(javaBuilder.currentProject)) {
446
		if (md.sourceFolder.equals(javaBuilder.currentProject)) {
435
			// skip nested source & output folders when the project is a source folder
447
			// skip nested source & output folders when the project is a source folder
436
			int segmentCount = delta.getFullPath().segmentCount();
448
			int segmentCount = delta.getFullPath().segmentCount();
Lines 440-456 Link Here
440
					if (!findSourceFiles(children[j], md, segmentCount))
452
					if (!findSourceFiles(children[j], md, segmentCount))
441
						return false;
453
						return false;
442
		} else {
454
		} else {
443
			if (this.makeOutputFolderConsistent && md.hasIndependentOutputFolder && !visited.contains(md.binaryFolder)) {
444
				visited.add(md.binaryFolder);
445
				IResourceDelta binaryDelta = delta.findMember(md.binaryFolder.getProjectRelativePath());
446
				if (binaryDelta != null) {
447
					int segmentCount = binaryDelta.getFullPath().segmentCount();
448
					IResourceDelta[] children = binaryDelta.getAffectedChildren();
449
					for (int j = 0, m = children.length; j < m; j++)
450
						if (!checkForClassFileChanges(children[j], md, segmentCount))
451
							return false;
452
				}
453
			}
454
			IResourceDelta sourceDelta = delta.findMember(md.sourceFolder.getProjectRelativePath());
455
			IResourceDelta sourceDelta = delta.findMember(md.sourceFolder.getProjectRelativePath());
455
			if (sourceDelta != null) {
456
			if (sourceDelta != null) {
456
				if (sourceDelta.getKind() == IResourceDelta.REMOVED) {
457
				if (sourceDelta.getKind() == IResourceDelta.REMOVED) {
(-)model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java (-4 / +13 lines)
Lines 219-234 Link Here
219
							if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
219
							if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
220
								IResource resource = proxy.requestResource();
220
								IResource resource = proxy.requestResource();
221
								if (exclusionPatterns != null || inclusionPatterns != null)
221
								if (exclusionPatterns != null || inclusionPatterns != null)
222
									if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false;
222
									if (Util.isExcluded(resource.getFullPath(), inclusionPatterns, exclusionPatterns, false))
223
										return false;
223
								sourceFiles.add(new SourceFile((IFile) resource, sourceLocation));
224
								sourceFiles.add(new SourceFile((IFile) resource, sourceLocation));
224
							}
225
							}
225
							return false;
226
							return false;
226
						case IResource.FOLDER :
227
						case IResource.FOLDER :
227
							if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null
228
								if (Util.isExcluded(proxy.requestResource(), inclusionPatterns, exclusionPatterns)) return false;
229
							IPath folderPath = null;
228
							IPath folderPath = null;
230
							if (isAlsoProject)
229
							if (isAlsoProject)
231
								if (isExcludedFromProject(folderPath = proxy.requestFullPath())) return false;
230
								if (isExcludedFromProject(folderPath = proxy.requestFullPath()))
231
									return false;
232
							if (exclusionPatterns != null) {
233
								if (folderPath == null)
234
									folderPath = proxy.requestFullPath();
235
								if (Util.isExcluded(folderPath, inclusionPatterns, exclusionPatterns, true)) {
236
									// must walk children if inclusionPatterns != null, can skip them if == null
237
									// but folder is excluded so do not create it in the output folder
238
									return inclusionPatterns != null;
239
								}
240
							}
232
							if (!isOutputFolder) {
241
							if (!isOutputFolder) {
233
								if (folderPath == null)
242
								if (folderPath == null)
234
									folderPath = proxy.requestFullPath();
243
									folderPath = proxy.requestFullPath();
(-)src/org/eclipse/jdt/core/tests/builder/CopyResourceTests.java (-11 / +35 lines)
Lines 31-63 Link Here
31
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=117302
31
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=117302
32
	public void testFilteredResources() throws JavaModelException {
32
	public void testFilteredResources() throws JavaModelException {
33
		IPath projectPath = env.addProject("P"); //$NON-NLS-1$
33
		IPath projectPath = env.addProject("P"); //$NON-NLS-1$
34
		IPath src = env.getPackageFragmentRootPath(projectPath, ""); //$NON-NLS-1$
34
		env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$
35
		env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$
35
		IPath src = env.addPackageFragmentRoot(
36
			projectPath,
37
			"", //$NON-NLS-1$
38
			new IPath[] {new org.eclipse.core.runtime.Path("foo/;bar/")}, //$NON-NLS-1$
39
			new IPath[] {new org.eclipse.core.runtime.Path("foo/ignored/")}, //$NON-NLS-1$
40
			"bin"); //$NON-NLS-1$
36
		env.addExternalJars(projectPath, Util.getJavaClassLibs());
41
		env.addExternalJars(projectPath, Util.getJavaClassLibs());
37
42
38
		env.addClass(src, "x", "A", //$NON-NLS-1$ //$NON-NLS-2$
43
		env.addClass(src, "foo", "A", //$NON-NLS-1$ //$NON-NLS-2$
39
			"package x;"+ //$NON-NLS-1$
44
			"package foo;"+ //$NON-NLS-1$
40
			"public class A extends q.B {}" //$NON-NLS-1$
45
			"public class A extends bar.B {}" //$NON-NLS-1$
41
		);
46
		);
42
		env.addClass(src, "q", "B", //$NON-NLS-1$ //$NON-NLS-2$
47
		env.addClass(src, "bar", "B", //$NON-NLS-1$ //$NON-NLS-2$
43
			"package q;"+ //$NON-NLS-1$
48
			"package bar;"+ //$NON-NLS-1$
44
			"public class B {}" //$NON-NLS-1$
49
			"public class B {}" //$NON-NLS-1$
45
		);
50
		);
46
		env.addFile(src.append("q"), "test.txt", "test file"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
51
		env.addFolder(src, "foo/skip"); //$NON-NLS-1$
52
		IPath ignored = env.addFolder(src, "foo/ignored"); //$NON-NLS-1$
53
		env.addFile(ignored, "test.txt", "test file"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
54
		env.addFile(src.append("bar"), "test.txt", "test file"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
55
47
		org.eclipse.jdt.core.IJavaProject p = env.getJavaProject("P");
56
		org.eclipse.jdt.core.IJavaProject p = env.getJavaProject("P");
48
		java.util.Map options = p.getOptions(true);
57
		java.util.Map options = p.getOptions(true);
49
		options.put(org.eclipse.jdt.core.JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, "q*"); //$NON-NLS-1$
58
		options.put(org.eclipse.jdt.core.JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, "bar*"); //$NON-NLS-1$
59
		options.put(org.eclipse.jdt.core.JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER, "enabled"); //$NON-NLS-1$
50
		p.setOptions(options);
60
		p.setOptions(options);
51
61
52
		int max = org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE;
62
		int max = org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE;
53
		try {
63
		try {
54
			org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE = 1;
64
			org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE = 1;
55
			fullBuild();
65
			fullBuild();
66
			expectingNoProblems();
67
			expectingNoPresenceOf(projectPath.append("bin/foo/skip/")); //$NON-NLS-1$
68
			expectingNoPresenceOf(projectPath.append("bin/foo/ignored/")); //$NON-NLS-1$
69
			expectingNoPresenceOf(projectPath.append("bin/bar/test.txt")); //$NON-NLS-1$
70
71
			env.removeFolder(projectPath.append("bin/bar")); //$NON-NLS-1$
72
			env.addClass(src, "x", "A", //$NON-NLS-1$ //$NON-NLS-2$
73
				"package x;"+ //$NON-NLS-1$
74
				"public class A extends bar.B {}" //$NON-NLS-1$
75
			);
76
			env.addFile(src.append("bar"), "test.txt", "changed test file"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
77
			incrementalBuild();
78
			expectingNoProblems();
79
			expectingNoPresenceOf(projectPath.append("bin/foo/skip/")); //$NON-NLS-1$
80
			expectingNoPresenceOf(projectPath.append("bin/foo/ignored/")); //$NON-NLS-1$
81
			expectingNoPresenceOf(projectPath.append("bin/bar/test.txt")); //$NON-NLS-1$
56
		} finally {
82
		} finally {
57
			org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE = max;
83
			org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.MAX_AT_ONCE = max;
58
		}
84
		}
59
		expectingNoProblems();
60
		expectingNoPresenceOf(projectPath.append("bin/q/test.txt")); //$NON-NLS-1$
61
	}
85
	}
62
86
63
	public void testSimpleProject() throws JavaModelException {
87
	public void testSimpleProject() throws JavaModelException {
(-)src/org/eclipse/jdt/core/tests/builder/MultiSourceFolderAndOutputFolderTests.java (-1 / +1 lines)
Lines 289-295 Link Here
289
	public void test0012() throws JavaModelException {
289
	public void test0012() throws JavaModelException {
290
		IPath projectPath = env.addProject("P");
290
		IPath projectPath = env.addProject("P");
291
		env.removePackageFragmentRoot(projectPath, "");
291
		env.removePackageFragmentRoot(projectPath, "");
292
		IPath src = env.addPackageFragmentRoot(projectPath, "", new IPath[] {new Path("p1/p2/p3/X.java"), new Path("Y.java")}, false/*inclusion*/, "");
292
		IPath src = env.addPackageFragmentRoot(projectPath, "", new IPath[] {new Path("p1/p2/p3/X.java"), new Path("Y.java")}, null, "");
293
		env.addExternalJars(projectPath, Util.getJavaClassLibs());
293
		env.addExternalJars(projectPath, Util.getJavaClassLibs());
294
		
294
		
295
		env.addClass(src, "p1.p2.p3", "X", 
295
		env.addClass(src, "p1.p2.p3", "X", 
(-)src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java (-9 / +7 lines)
Lines 142-148 Link Here
142
	 * Returns the path of the added package fragment root.
142
	 * Returns the path of the added package fragment root.
143
	 */
143
	 */
144
	public IPath addPackageFragmentRoot(IPath projectPath, String sourceFolderName, IPath[] exclusionPatterns, String specificOutputLocation) throws JavaModelException {
144
	public IPath addPackageFragmentRoot(IPath projectPath, String sourceFolderName, IPath[] exclusionPatterns, String specificOutputLocation) throws JavaModelException {
145
		return addPackageFragmentRoot(projectPath, sourceFolderName, exclusionPatterns, true/*exclusion patterns*/, specificOutputLocation);
145
		return addPackageFragmentRoot(projectPath, sourceFolderName, null, exclusionPatterns, specificOutputLocation);
146
	}
146
	}
147
	
147
	
148
	/** Adds a package fragment root to the workspace.  If
148
	/** Adds a package fragment root to the workspace.  If
Lines 150-156 Link Here
150
	 * exists, it is not replaced.  A workspace must be open.
150
	 * exists, it is not replaced.  A workspace must be open.
151
	 * Returns the path of the added package fragment root.
151
	 * Returns the path of the added package fragment root.
152
	 */
152
	 */
153
	public IPath addPackageFragmentRoot(IPath projectPath, String sourceFolderName, IPath[] patterns, boolean areExclusionPatterns, String specificOutputLocation) throws JavaModelException {
153
	public IPath addPackageFragmentRoot(IPath projectPath, String sourceFolderName, IPath[] inclusionPatterns, IPath[] exclusionPatterns, String specificOutputLocation) throws JavaModelException {
154
		checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
154
		checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
155
		IPath path = getPackageFragmentRootPath(projectPath, sourceFolderName);
155
		IPath path = getPackageFragmentRootPath(projectPath, sourceFolderName);
156
		createFolder(path);
156
		createFolder(path);
Lines 159-171 Link Here
159
			outputPath = getPackageFragmentRootPath(projectPath, specificOutputLocation);
159
			outputPath = getPackageFragmentRootPath(projectPath, specificOutputLocation);
160
			createFolder(outputPath);
160
			createFolder(outputPath);
161
		}
161
		}
162
		IClasspathEntry entry;
162
		IClasspathEntry entry = JavaCore.newSourceEntry(
163
		if (areExclusionPatterns)
163
			path,
164
			// exclusion patterns
164
			inclusionPatterns == null ? new Path[0] : inclusionPatterns,
165
			entry = JavaCore.newSourceEntry(path, patterns == null ? new Path[0] : patterns, outputPath);
165
			exclusionPatterns == null ? new Path[0] : exclusionPatterns,
166
		else
166
			outputPath);
167
			// inclusion patterns
168
			entry = JavaCore.newSourceEntry(path, patterns == null ? new Path[0] : patterns, new Path[0], outputPath);
169
		addEntry(projectPath, entry);
167
		addEntry(projectPath, entry);
170
		return path;
168
		return path;
171
	}
169
	}

Return to bug 157336