diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/builder/PMDBuilder.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/builder/PMDBuilder.java index 8db9f0f1b4..ee031d6a9d 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/builder/PMDBuilder.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/builder/PMDBuilder.java @@ -27,7 +27,7 @@ public class PMDBuilder extends IncrementalProjectBuilder { public static final Logger log = Logger.getLogger(PMDBuilder.class); public static final String PMD_BUILDER = "net.sourceforge.pmd.eclipse.plugin.pmdBuilder"; - IProject[] EMPTY_PROJECT_ARRAY = new IProject[0]; + public static final IProject[] EMPTY_PROJECT_ARRAY = new IProject[0]; /** * @see org.eclipse.core.resources.IncrementalProjectBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor) */ diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/JavaProjectClassLoader.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/JavaProjectClassLoader.java index 4d64893f4c..77025dadbc 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/JavaProjectClassLoader.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/JavaProjectClassLoader.java @@ -35,53 +35,54 @@ public class JavaProjectClassLoader extends URLClassLoader { } private void addURLs(IJavaProject javaProject, boolean exportsOnly) { - if (!javaProjects.contains(javaProject)) { - javaProjects.add(javaProject); + + if (javaProjects.contains(javaProject)) return; + + javaProjects.add(javaProject); - try { - // Add default output location - addURL(javaProject.getOutputLocation()); + try { + // Add default output location + addURL(javaProject.getOutputLocation()); - // Add each classpath entry - IClasspathEntry[] classpathEntries = javaProject.getResolvedClasspath(true); - for (IClasspathEntry classpathEntry : classpathEntries) { - if (classpathEntry.isExported() || !exportsOnly) { - switch (classpathEntry.getEntryKind()) { + // Add each classpath entry + IClasspathEntry[] classpathEntries = javaProject.getResolvedClasspath(true); + for (IClasspathEntry classpathEntry : classpathEntries) { + if (classpathEntry.isExported() || !exportsOnly) { + switch (classpathEntry.getEntryKind()) { - // Recurse on projects - case IClasspathEntry.CPE_PROJECT: - IProject project = javaProject.getProject().getWorkspace().getRoot().getProject( - classpathEntry.getPath().toString()); - IJavaProject javaProj = JavaCore.create(project); - if (javaProj != null) { - addURLs(javaProj, true); + // Recurse on projects + case IClasspathEntry.CPE_PROJECT: + IProject project = javaProject.getProject().getWorkspace().getRoot().getProject( + classpathEntry.getPath().toString()); + IJavaProject javaProj = JavaCore.create(project); + if (javaProj != null) { + addURLs(javaProj, true); } - break; + break; // Library - case IClasspathEntry.CPE_LIBRARY: - addURL(classpathEntry); - break; + case IClasspathEntry.CPE_LIBRARY: + addURL(classpathEntry); + break; - // Only Source entries with custom output location need to be added - case IClasspathEntry.CPE_SOURCE: - IPath outputLocation = classpathEntry.getOutputLocation(); - if (outputLocation != null) { - addURL(outputLocation); + // Only Source entries with custom output location need to be added + case IClasspathEntry.CPE_SOURCE: + IPath outputLocation = classpathEntry.getOutputLocation(); + if (outputLocation != null) { + addURL(outputLocation); } - break; + break; - // Variable and Container entries should not be happening, because we've asked for resolved entries. - case IClasspathEntry.CPE_VARIABLE: - case IClasspathEntry.CPE_CONTAINER: - break; - } + // Variable and Container entries should not be happening, because we've asked for resolved entries. + case IClasspathEntry.CPE_VARIABLE: + case IClasspathEntry.CPE_CONTAINER: + break; } } - } catch (JavaModelException e) { - log.debug("MalformedURLException occurred: " + e.getLocalizedMessage(), e); } - } + } catch (JavaModelException e) { + log.debug("MalformedURLException occurred: " + e.getLocalizedMessage(), e); + } } private void addURL(IClasspathEntry classpathEntry) {