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

Collapse All | Expand All

(-)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/TestingEnvironment.java (-9 / +7 lines)
Lines 133-139 Link Here
133
	 * Returns the path of the added package fragment root.
133
	 * Returns the path of the added package fragment root.
134
	 */
134
	 */
135
	public IPath addPackageFragmentRoot(IPath projectPath, String sourceFolderName, IPath[] exclusionPatterns, String specificOutputLocation) throws JavaModelException {
135
	public IPath addPackageFragmentRoot(IPath projectPath, String sourceFolderName, IPath[] exclusionPatterns, String specificOutputLocation) throws JavaModelException {
136
		return addPackageFragmentRoot(projectPath, sourceFolderName, exclusionPatterns, true/*exclusion patterns*/, specificOutputLocation);
136
		return addPackageFragmentRoot(projectPath, sourceFolderName, null, exclusionPatterns, specificOutputLocation);
137
	}
137
	}
138
	
138
	
139
	/** Adds a package fragment root to the workspace.  If
139
	/** Adds a package fragment root to the workspace.  If
Lines 141-147 Link Here
141
	 * exists, it is not replaced.  A workspace must be open.
141
	 * exists, it is not replaced.  A workspace must be open.
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[] patterns, boolean areExclusionPatterns, String specificOutputLocation) throws JavaModelException {
144
	public IPath addPackageFragmentRoot(IPath projectPath, String sourceFolderName, IPath[] inclusionPatterns, IPath[] exclusionPatterns, String specificOutputLocation) throws JavaModelException {
145
		checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
145
		checkAssertion("a workspace must be open", fIsOpen); //$NON-NLS-1$
146
		IPath path = getPackageFragmentRootPath(projectPath, sourceFolderName);
146
		IPath path = getPackageFragmentRootPath(projectPath, sourceFolderName);
147
		createFolder(path);
147
		createFolder(path);
Lines 150-162 Link Here
150
			outputPath = getPackageFragmentRootPath(projectPath, specificOutputLocation);
150
			outputPath = getPackageFragmentRootPath(projectPath, specificOutputLocation);
151
			createFolder(outputPath);
151
			createFolder(outputPath);
152
		}
152
		}
153
		IClasspathEntry entry;
153
		IClasspathEntry entry = JavaCore.newSourceEntry(
154
		if (areExclusionPatterns)
154
			path,
155
			// exclusion patterns
155
			inclusionPatterns == null ? new Path[0] : inclusionPatterns,
156
			entry = JavaCore.newSourceEntry(path, patterns == null ? new Path[0] : patterns, outputPath);
156
			exclusionPatterns == null ? new Path[0] : exclusionPatterns,
157
		else
157
			outputPath);
158
			// inclusion patterns
159
			entry = JavaCore.newSourceEntry(path, patterns == null ? new Path[0] : patterns, new Path[0], outputPath);
160
		addEntry(projectPath, entry);
158
		addEntry(projectPath, entry);
161
		return path;
159
		return path;
162
	}
160
	}
(-)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", 
(-)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 218-233 Link Here
218
							if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
218
							if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) {
219
								IResource resource = proxy.requestResource();
219
								IResource resource = proxy.requestResource();
220
								if (exclusionPatterns != null || inclusionPatterns != null)
220
								if (exclusionPatterns != null || inclusionPatterns != null)
221
									if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false;
221
									if (Util.isExcluded(resource.getFullPath(), inclusionPatterns, exclusionPatterns, false))
222
										return false;
222
								sourceFiles.add(new SourceFile((IFile) resource, sourceLocation));
223
								sourceFiles.add(new SourceFile((IFile) resource, sourceLocation));
223
							}
224
							}
224
							return false;
225
							return false;
225
						case IResource.FOLDER :
226
						case IResource.FOLDER :
226
							if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null
227
								if (Util.isExcluded(proxy.requestResource(), inclusionPatterns, exclusionPatterns)) return false;
228
							IPath folderPath = null;
227
							IPath folderPath = null;
229
							if (isAlsoProject)
228
							if (isAlsoProject)
230
								if (isExcludedFromProject(folderPath = proxy.requestFullPath())) return false;
229
								if (isExcludedFromProject(folderPath = proxy.requestFullPath()))
230
									return false;
231
							if (exclusionPatterns != null) {
232
								if (folderPath == null)
233
									folderPath = proxy.requestFullPath();
234
								if (Util.isExcluded(folderPath, inclusionPatterns, exclusionPatterns, true)) {
235
									// must walk children if inclusionPatterns != null, can skip them if == null
236
									// but folder is excluded so do not create it in the output folder
237
									return inclusionPatterns != null;
238
								}
239
							}
231
							if (!isOutputFolder) {
240
							if (!isOutputFolder) {
232
								if (folderPath == null)
241
								if (folderPath == null)
233
									folderPath = proxy.requestFullPath();
242
									folderPath = proxy.requestFullPath();

Return to bug 157336