### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ClasspathTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java,v retrieving revision 1.151 diff -u -r1.151 ClasspathTests.java --- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 6 Apr 2006 15:25:04 -0000 1.151 +++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 10 Apr 2006 13:54:37 -0000 @@ -1627,8 +1627,8 @@ this.deleteProject("P"); } } -/** - * 62713 - variation +/* + * Ensures that a source folder with a custom output can be nested in the default output */ public void testClasspathValidation41() throws CoreException { try { @@ -1642,7 +1642,7 @@ IJavaModelStatus status = JavaConventions.validateClasspath(proj, newCP, proj.getOutputLocation()); assertStatus( - "Cannot nest \'P/src\' inside output folder \'P/\'", + "OK", status); } finally { this.deleteProject("P"); @@ -1672,6 +1672,29 @@ this.deleteProject("P"); } } +/* + * Ensure that a custom output folder cannot be nested in the default output folder + * (regression test for bug 80756 Multiple source folders to one bin forgot copy some files) + */ +public void testClasspathValidation43() throws CoreException { + try { + IJavaProject proj = createJavaProject("P", new String[] {}, ""); + IClasspathEntry[] originalCP = proj.getRawClasspath(); + + IClasspathEntry[] newCP = new IClasspathEntry[originalCP.length+2]; + System.arraycopy(originalCP, 0, newCP, 0, originalCP.length); + newCP[originalCP.length] = JavaCore.newSourceEntry(new Path("/P/src1"), new IPath[0], new Path("/P/bin")); + newCP[originalCP.length+1] = JavaCore.newSourceEntry(new Path("/P/src2")); + + IJavaModelStatus status = JavaConventions.validateClasspath(proj, newCP, new Path("/P/bin/default")); + + assertStatus( + "Cannot nest output folder \'P/bin/default\' inside output folder \'P/bin\'", + status); + } finally { + deleteProject("P"); + } +} /** * Setting the classpath with two entries specifying the same path * should fail. #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/ClasspathEntry.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java,v retrieving revision 1.92 diff -u -r1.92 ClasspathEntry.java --- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 6 Apr 2006 01:47:51 -0000 1.92 +++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 10 Apr 2006 13:54:40 -0000 @@ -1377,6 +1377,16 @@ } } } + // check nesting of project's output in custom output + int projectOutputIndex; + if ((projectOutputIndex = Util.indexOfEnclosingPath(projectOutputLocation, outputLocations, outputCount)) > 0) { + // allow project's output nesting in custom output if all source entries have a custom output + if (sourceEntryCount <= outputCount-1) { + allowNestingInOutputLocations[projectOutputIndex] = true; + } else { + return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestOutputInOutput, new String[] {projectOutputLocation.makeRelative().toString(), outputLocations[projectOutputIndex].makeRelative().toString()})); + } + } // allow custom output nesting in project's output if all source entries have a custom output if (sourceEntryCount <= outputCount-1) { allowNestingInOutputLocations[0] = true;