### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java,v retrieving revision 1.69 diff -u -r1.69 JDTCompilerAdapter.java --- antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java 25 Apr 2010 20:10:09 -0000 1.69 +++ antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java 28 Sep 2010 17:56:46 -0000 @@ -119,8 +119,6 @@ } } - Path classpath = new Path(this.project); - /* * Eclipse compiler doesn't support -extdirs. * It is emulated using the classpath. We add extdirs entries after the @@ -131,11 +129,17 @@ cmd.createArgument().setPath(this.extdirs); } + Path classpath = new Path(this.project); /* * The java runtime is already handled, so we simply want to retrieve the * ant runtime and the compile classpath. */ classpath.append(getCompileClasspath()); + /* + * Set the classpath for the Eclipse compiler. + */ + cmd.createArgument().setValue("-classpath"); //$NON-NLS-1$ + createClasspathArgument(cmd, classpath); // For -sourcepath, use the "sourcepath" value if present. // Otherwise default to the "srcdir" value. @@ -164,12 +168,8 @@ } else { sourcepath = this.src; } - classpath.append(sourcepath); - /* - * Set the classpath for the Eclipse compiler. - */ - cmd.createArgument().setValue("-classpath"); //$NON-NLS-1$ - createClasspathArgument(cmd, classpath); + cmd.createArgument().setValue("-sourcepath"); //$NON-NLS-1$ + createClasspathArgument(cmd, sourcepath); final String javaVersion = JavaEnvUtils.getJavaVersion(); String memoryParameterPrefix = javaVersion.equals(JavaEnvUtils.JAVA_1_1) ? "-J-" : "-J-X";//$NON-NLS-1$//$NON-NLS-2$ Index: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java,v retrieving revision 1.57 diff -u -r1.57 ClasspathDirectory.java --- batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java 19 Aug 2010 06:26:31 -0000 1.57 +++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java 28 Sep 2010 17:56:46 -0000 @@ -28,7 +28,7 @@ private Hashtable directoryCache; private String[] missingPackageHolder = new String[1]; -private int mode; // ability to only consider one kind of files (source vs. binaries), by default use both +int mode; // ability to only consider one kind of files (source vs. binaries), by default use both private String encoding; // only useful if referenced in the source path ClasspathDirectory(File directory, String encoding, int mode, Index: batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java,v retrieving revision 1.55 diff -u -r1.55 FileSystem.java --- batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java 21 Feb 2010 03:35:52 -0000 1.55 +++ batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java 28 Sep 2010 17:56:46 -0000 @@ -201,13 +201,37 @@ fileName = CharOperation.subarray(fileName, 0, lastIndexOf); } CharOperation.replace(fileName, '\\', '/'); + boolean sourcePathMatches = false; + // a source path folder should match over a classpath entry set up for both source and binary for (int j = 0, max = this.classpaths.length; j < max; j++) { char[] matchCandidate = this.classpaths[j].normalizedPath(); - if (this.classpaths[j] instanceof ClasspathDirectory && - CharOperation.prefixEquals(matchCandidate, fileName) && - (matchingPathName == null || - matchCandidate.length < matchingPathName.length)) { - matchingPathName = matchCandidate; + boolean currentSourcePathMatch = false; + if (this.classpaths[j] instanceof ClasspathDirectory + && CharOperation.prefixEquals(matchCandidate, fileName)) { + ClasspathDirectory classpathDirectory = (ClasspathDirectory) this.classpaths[j]; + if ((classpathDirectory.mode & (ClasspathLocation.SOURCE | ClasspathLocation.BINARY)) == ClasspathLocation.SOURCE) { + currentSourcePathMatch = true; + } + if (matchingPathName == null) { + matchingPathName = matchCandidate; + } else { + // if not null, we must keep the current classpath directory if this is a source path folder + if (currentSourcePathMatch) { + // we have a second source folder that matches the path of the source file + if (matchCandidate.length > matchingPathName.length) { + // we want to preserve the shortest possible path + matchingPathName = matchCandidate; + } + } else { + // if (sourcePathMatches) one former source paths matched - ignore the current match + if (!sourcePathMatches && matchCandidate.length < matchingPathName.length) { + matchingPathName = matchCandidate; + } + } + } + if (currentSourcePathMatch) { + sourcePathMatches = true; + } } } if (matchingPathName == null) {