Bug 377231 - PDE classpath container does not support external non-jarred plug-ins without libraries
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEClasspathContainer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEClasspathContainer.java
index 1e3251d..d80d495 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEClasspathContainer.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEClasspathContainer.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- *  Copyright (c) 2005, 2011 IBM Corporation and others.
+ *  Copyright (c) 2005, 2012 IBM Corporation and others.
  *  All rights reserved. This program and the accompanying materials
  *  are made available under the terms of the Eclipse Public License v1.0
  *  which accompanies this distribution, and is available at
@@ -76,20 +76,28 @@
 			}
 		} else {
 			IPluginLibrary[] libraries = model.getPluginBase().getLibraries();
-			for (int i = 0; i < libraries.length; i++) {
-				if (IPluginLibrary.RESOURCE.equals(libraries[i].getType()))
-					continue;
-				model = (IPluginModelBase) libraries[i].getModel();
-				String name = libraries[i].getName();
-				String expandedName = ClasspathUtilCore.expandLibraryName(name);
-				IPath path = ClasspathUtilCore.getPath(model, expandedName);
-				if (path == null && !model.isFragmentModel() && ClasspathUtilCore.containsVariables(name)) {
-					model = resolveLibraryInFragments(model, expandedName);
-					if (model != null && model.isEnabled())
-						path = ClasspathUtilCore.getPath(model, expandedName);
+			if (libraries.length == 0) {
+				// If there are no libraries, assume the root of the plug-in is the library '.'
+				IPath srcPath = ClasspathUtilCore.getSourceAnnotation(model, "."); //$NON-NLS-1$
+				if (srcPath == null)
+					srcPath = new Path(model.getInstallLocation());
+				addLibraryEntry(new Path(model.getInstallLocation()), srcPath, rules, getClasspathAttributes(model), entries);
+			} else {
+				for (int i = 0; i < libraries.length; i++) {
+					if (IPluginLibrary.RESOURCE.equals(libraries[i].getType()))
+						continue;
+					model = (IPluginModelBase) libraries[i].getModel();
+					String name = libraries[i].getName();
+					String expandedName = ClasspathUtilCore.expandLibraryName(name);
+					IPath path = ClasspathUtilCore.getPath(model, expandedName);
+					if (path == null && !model.isFragmentModel() && ClasspathUtilCore.containsVariables(name)) {
+						model = resolveLibraryInFragments(model, expandedName);
+						if (model != null && model.isEnabled())
+							path = ClasspathUtilCore.getPath(model, expandedName);
+					}
+					if (path != null)
+						addLibraryEntry(path, ClasspathUtilCore.getSourceAnnotation(model, expandedName), rules, getClasspathAttributes(model), entries);
 				}
-				if (path != null)
-					addLibraryEntry(path, ClasspathUtilCore.getSourceAnnotation(model, expandedName), rules, getClasspathAttributes(model), entries);
 			}
 		}
 	}
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginBase.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginBase.java
index b6fa80c..5f79988 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginBase.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/plugin/PluginBase.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- *  Copyright (c) 2000, 2008 IBM Corporation and others.
+ *  Copyright (c) 2000, 2012 IBM Corporation and others.
  *  All rights reserved. This program and the accompanying materials
  *  are made available under the terms of the Eclipse Public License v1.0
  *  which accompanies this distribution, and is available at
@@ -12,24 +12,12 @@
 
 import java.util.ArrayList;
 import java.util.Locale;
-
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
+import javax.xml.parsers.*;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.osgi.service.resolver.BundleDescription;
-import org.eclipse.osgi.service.resolver.BundleSpecification;
-import org.eclipse.osgi.service.resolver.VersionRange;
+import org.eclipse.osgi.service.resolver.*;
 import org.eclipse.pde.core.IModelChangedEvent;
-import org.eclipse.pde.core.plugin.IMatchRules;
-import org.eclipse.pde.core.plugin.IPluginBase;
-import org.eclipse.pde.core.plugin.IPluginImport;
-import org.eclipse.pde.core.plugin.IPluginLibrary;
-import org.eclipse.pde.internal.core.PDECoreMessages;
-import org.eclipse.pde.internal.core.PDEState;
-import org.eclipse.pde.internal.core.PDEStateHelper;
+import org.eclipse.pde.core.plugin.*;
+import org.eclipse.pde.internal.core.*;
 import org.osgi.framework.Version;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -78,7 +66,12 @@
 		fireStructureChanged(iimports, IModelChangedEvent.INSERT);
 	}
 
+	/* (non-Javadoc)
+	 * @see org.eclipse.pde.core.plugin.IPluginBase#getLibraries()
+	 */
 	public IPluginLibrary[] getLibraries() {
+		// Returns an empty array if no libraries are specified in the manifest of the plug-in.
+		// If no libraries are specified, the root of the bundle '.' is the default library location
 		return (IPluginLibrary[]) fLibraries.toArray(new IPluginLibrary[fLibraries.size()]);
 	}