Skip to content
Browse files

397173 : disambiguate duplicate workspace projects

Signed-off-by: Fred Bricon <fbricon@gmail.com>
  • Loading branch information...
1 parent 06e82f5 commit 7afdac3571c698b7141fe2b9fbd555300d2cacca @fbricon fbricon committed Feb 5, 2013
View
4 org.eclipse.m2e.wtp/src/org/eclipse/m2e/wtp/IProjectConfiguratorDelegate.java
@@ -18,6 +18,10 @@
/**
* Configure projects based on maven plugin configuration.
*
+ * @provisional This class has been added as part of a work in progress.
+ * It is not guaranteed to work or remain the same in future releases.
+ * For more information contact <a href="mailto:m2e-wtp-dev@eclipse.org">m2e-wtp-dev@eclipse.org</a>.
+ *
* @author Fred Bricon
*/
interface IProjectConfiguratorDelegate {
View
28 org.eclipse.m2e.wtp/src/org/eclipse/m2e/wtp/WebProjectConfiguratorDelegate.java
@@ -13,10 +13,12 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
@@ -223,6 +225,10 @@ public void setModuleDependencies(IProject project, MavenProject mavenProject, I
Set<IVirtualReference> references = new LinkedHashSet<IVirtualReference>();
List<IMavenProjectFacade> exportedDependencies = getWorkspaceDependencies(project, mavenProject);
+
+ Set<String> dups = new HashSet<String>();
+ Set<String> names = new HashSet<String>();
+ Map<IVirtualReference, Artifact> referenceMapping = new HashMap<IVirtualReference, Artifact>(exportedDependencies.size());
for(IMavenProjectFacade dependency : exportedDependencies) {
String depPackaging = dependency.getPackaging();
if ("pom".equals(depPackaging) //MNGECLIPSE-744 pom dependencies shouldn't be deployed
@@ -261,6 +267,11 @@ public void setModuleDependencies(IProject project, MavenProject mavenProject, I
reference.setArchiveName(deployedName);
reference.setRuntimePath(path);
references.add(reference);
+
+ referenceMapping.put(reference, artifact);
+ if (!names.add(deployedName)) {
+ dups.add(deployedName);
+ }
}
} catch(RuntimeException ex) {
//Should probably be NPEs at this point
@@ -270,6 +281,13 @@ public void setModuleDependencies(IProject project, MavenProject mavenProject, I
}
}
+ for (IVirtualReference reference : references) {
+ if (dups.contains(reference.getArchiveName())) {
+ Artifact a = referenceMapping.get(reference);
+ String newName = a.getGroupId() + "-" + reference.getArchiveName();
+ reference.setArchiveName(newName);
+ }
+ }
IVirtualReference[] oldRefs = WTPProjectsUtil.extractHardReferences(component, false);
@@ -343,6 +361,16 @@ public void configureClasspath(IProject project, MavenProject mavenProject, ICla
Set<String> dups = new LinkedHashSet<String>();
Set<String> names = new HashSet<String>();
+
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if (component != null) {
+ for (IVirtualReference vr : component.getReferences()) {
+ if (!vr.getReferencedComponent().isBinary()) {
+ names.add(vr.getArchiveName());
+ }
+ }
+ }
+
FileNameMapping fileNameMapping = config.getFileNameMapping();
String targetDir = mavenProject.getBuild().getDirectory();

0 comments on commit 7afdac3

Please sign in to comment.
Something went wrong with that request. Please try again.