[409049] [regression] Generate Deployment Descriptor ignores
tag=defaultRootSource
diff --git a/plugins/org.eclipse.wst.common.modulecore/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.common.modulecore/META-INF/MANIFEST.MF
index 8855f0d..2e047ef 100644
--- a/plugins/org.eclipse.wst.common.modulecore/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.common.modulecore/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Name: %Bundle-Name.0
Bundle-Vendor: %provider
Bundle-SymbolicName: org.eclipse.wst.common.modulecore; singleton:=true
-Bundle-Version: 1.2.300.qualifier
+Bundle-Version: 1.2.301.qualifier
Bundle-Activator: org.eclipse.wst.common.componentcore.internal.ModulecorePlugin
Bundle-Localization: plugin
Export-Package: org.eclipse.wst.common.componentcore,
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualResource.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualResource.java
index c8815de..16c2c51 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualResource.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualResource.java
@@ -116,6 +116,7 @@
public IPath[] getProjectRelativePaths() {
WorkbenchComponent aComponent = getReadOnlyComponent();
+ IPath defaultSrcRoot = ((WorkbenchComponentImpl)aComponent).getDefaultSourceRoot();
if (aComponent != null) {
ResourceTreeRoot root = ResourceTreeRoot.getDeployResourceTreeRoot(aComponent);
// still need some sort of loop here to search subpieces of the
@@ -130,7 +131,7 @@
if (searchPath.isAbsolute())
searchPath = searchPath.makeRelative();
componentResources = root.findModuleResources(searchPath, ResourceTreeNode.CREATE_NONE);
- estimatedPaths = findBestMatches(componentResources);
+ estimatedPaths = findBestMatches(componentResources, defaultSrcRoot);
}
while (estimatedPaths.length == 0 && canSearchContinue(componentResources, searchPath));
if (estimatedPaths == null || estimatedPaths.length == 0)
@@ -157,7 +158,7 @@
return (searchPath.segmentCount() > 0);
}
- private IPath[] findBestMatches(ComponentResource[] theComponentResources) {
+ private IPath[] findBestMatches(ComponentResource[] theComponentResources, IPath defaultRoot) {
List result = new ArrayList();
int currentMatchLength = 0;
int bestMatchLength = -1;
@@ -177,6 +178,13 @@
IPath sourcePath = theComponentResources[i].getSourcePath();
IPath subpath = aRuntimePath.removeFirstSegments(currentMatchLength);
estimatedPath = sourcePath.append(subpath);
+ } else if( currentMatchLength == currentPath.segmentCount() && currentMatchLength == bestMatchLength) {
+ // We match the same length. If the new one has the default label, then choose the new one
+ bestMatchLength = currentMatchLength;
+ IPath sourcePath = theComponentResources[i].getSourcePath();
+ IPath subpath = aRuntimePath.removeFirstSegments(currentMatchLength);
+ if( sourcePath.equals(defaultRoot))
+ estimatedPath = sourcePath.append(subpath);
}
}
}