Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2014-04-18 21:52:54 +0000
committerIgor Fedorenko2014-04-20 23:04:43 +0000
commit150c457edc53494dd4d48bb72454f998e08473e7 (patch)
treeff56198685d0ffd373c3d9405b93625ac930d327
parent86e1ca34912a6da5882f6cc3283f84ed22bdf3b1 (diff)
downloadm2e-core-150c457edc53494dd4d48bb72454f998e08473e7.tar.gz
m2e-core-150c457edc53494dd4d48bb72454f998e08473e7.tar.xz
m2e-core-150c457edc53494dd4d48bb72454f998e08473e7.zip
432436 ability to configure maven installation extensions WIP
Change-Id: Iddef9107e5c75a287e4ca58cd04c898cc0177811 Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties4
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ArchiveEntryNode.java28
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ClassRealmNode.java46
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizardPage.java109
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ProjectEntryNode.java30
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntimeManager.java10
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java2
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/AbstractMavenRuntime.java52
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/AbstractWorkspaceRuntime.java3
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/ClasspathEntry.java12
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenEmbeddedRuntime.java1
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenExternalRuntime.java15
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/ProjectClasspathEntry.java (renamed from org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ClasspathEntryNode.java)19
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties1
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/MavenLaunchConstants.java3
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchUtils.java48
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLauncherConfigurationHandler.java20
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenRuntimeLaunchSupport.java5
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenSourcePathComputer.java1
19 files changed, 181 insertions, 228 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
index 4247de28..4bca224e 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
@@ -1,5 +1,5 @@
#Eclipse modern messages class
-#Fri Apr 18 19:09:55 MSK 2014
+#Sat Apr 19 00:39:56 MSK 2014
AddDependencyAction_error_msg=Can't add dependency to {0}
AddDependencyAction_error_title=Add Dependency
AddDependencyAction_searchDialog_title=Add Dependency
@@ -53,7 +53,7 @@ ExternalInstallPage_btnRemove_text=Remove
ExternalInstallPage_btnRestoreDefault_text=Restore Default
ExternalInstallPage_btnUp_text=Up
ExternalInstallPage_description=Specify attributes for a Maven installation
-ExternalInstallPage_lblInstallationLibraries_text=Installation libraries\:
+ExternalInstallPage_lblInstallationLibraries_text=Additional extension libraries\:
ExternalInstallPage_lblInstallationLocation_text=Installation home\:
ExternalInstallPage_lblInstallationName_text=Installation name\:
ExternalInstallPage_pageName=External Installation
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ArchiveEntryNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ArchiveEntryNode.java
deleted file mode 100644
index d9c7bb23..00000000
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ArchiveEntryNode.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Takari, Inc.
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Takari, Inc. - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.m2e.core.ui.internal.preferences.launch;
-
-public class ArchiveEntryNode extends ClasspathEntryNode {
-
- private String location;
-
- public ArchiveEntryNode(ClassRealmNode realm, String location) {
- super(realm);
- this.location = location;
- }
-
- @Override
- public String getName() {
- return location;
- }
-
-}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ClassRealmNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ClassRealmNode.java
deleted file mode 100644
index 52646d09..00000000
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ClassRealmNode.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Takari, Inc.
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Takari, Inc. - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.m2e.core.ui.internal.preferences.launch;
-
-import java.util.List;
-
-
-public class ClassRealmNode {
- private String name;
-
- private List<ClasspathEntryNode> classpath;
-
- public ClassRealmNode(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public List<ClasspathEntryNode> getClasspath() {
- return classpath;
- }
-
- public void setClasspath(List<ClasspathEntryNode> classpath) {
- this.classpath = classpath;
- }
-
- public int getIndex(ClasspathEntryNode entry) {
- for(int i = 0; i < classpath.size(); i++ ) {
- if(classpath.get(i) == entry) {
- return i;
- }
- }
- return 0;
- }
-}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizardPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizardPage.java
index 3872207b..90ba6cc2 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizardPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizardPage.java
@@ -14,6 +14,7 @@ package org.eclipse.m2e.core.ui.internal.preferences.launch;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IProject;
@@ -46,7 +47,9 @@ import org.eclipse.ui.dialogs.ListSelectionDialog;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.internal.launch.AbstractMavenRuntime;
+import org.eclipse.m2e.core.internal.launch.ClasspathEntry;
import org.eclipse.m2e.core.internal.launch.MavenExternalRuntime;
+import org.eclipse.m2e.core.internal.launch.ProjectClasspathEntry;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.ui.internal.Messages;
import org.eclipse.m2e.core.ui.internal.components.MavenProjectLabelProvider;
@@ -55,7 +58,7 @@ import org.eclipse.m2e.core.ui.internal.components.MavenProjectLabelProvider;
@SuppressWarnings("restriction")
public class MavenInstallationWizardPage extends WizardPage {
- private List<ClassRealmNode> realms;
+ private List<ClasspathEntry> extensions;
private Text location;
@@ -86,9 +89,6 @@ public class MavenInstallationWizardPage extends WizardPage {
}
public Object[] getChildren(Object parentElement) {
- if(parentElement instanceof ClassRealmNode) {
- return ((ClassRealmNode) parentElement).getClasspath().toArray();
- }
return null;
}
@@ -97,7 +97,7 @@ public class MavenInstallationWizardPage extends WizardPage {
}
public boolean hasChildren(Object element) {
- return element instanceof ClassRealmNode;
+ return false;
}
}
@@ -122,12 +122,10 @@ public class MavenInstallationWizardPage extends WizardPage {
}
public String getText(Object element) {
- if(element instanceof ClassRealmNode) {
- return ((ClassRealmNode) element).getName();
- } else if(element instanceof ClasspathEntryNode) {
- return ((ClasspathEntryNode) element).getName();
+ if(element instanceof ProjectClasspathEntry) {
+ return ((ProjectClasspathEntry) element).getProject();
}
- return null;
+ return element.toString();
}
}
@@ -136,22 +134,8 @@ public class MavenInstallationWizardPage extends WizardPage {
this.original = original;
setDescription(Messages.ExternalInstallPage_description);
- List<ClassRealmNode> realms = new ArrayList<ClassRealmNode>();
-// for(Map.Entry<String, List<String>> realm : installation.getRealms().entrySet()) {
-// ClassRealmNode realmNode = new ClassRealmNode(realm.getKey());
-// realmNode.setClasspath(toClasspathEntries(realmNode, realm.getValue()));
-// realms.add(realmNode);
-// }
- this.realms = realms;
-
- }
-
- public List<ClasspathEntryNode> toClasspathEntries(ClassRealmNode realm, List<String> classpath) {
- List<ClasspathEntryNode> result = new ArrayList<ClasspathEntryNode>();
- for(String entry : classpath) {
- result.add(new ArchiveEntryNode(realm, entry));
- }
- return result;
+ this.extensions = original != null && original.getExtensions() != null ? original.getExtensions()
+ : new ArrayList<ClasspathEntry>();
}
public void createControl(Composite parent) {
@@ -205,7 +189,7 @@ public class MavenInstallationWizardPage extends WizardPage {
});
treeViewerLibrariries.setContentProvider(new TreeContentProvider());
treeViewerLibrariries.setLabelProvider(new TreeLabelProvider());
- treeViewerLibrariries.setInput(realms);
+ treeViewerLibrariries.setInput(extensions);
Tree treeLibraries = treeViewerLibrariries.getTree();
treeLibraries.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 5));
@@ -213,25 +197,49 @@ public class MavenInstallationWizardPage extends WizardPage {
btnAddProject.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- addProjectAction();
+ addProjectExtensionAction();
}
});
btnAddProject.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnAddProject.setText(Messages.ExternalInstallPage_btnAddProject_text);
btnRemove = new Button(container, SWT.NONE);
+ btnRemove.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ removeExtensionAction();
+ }
+ });
btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnRemove.setText(Messages.ExternalInstallPage_btnRemove_text);
btnUp = new Button(container, SWT.NONE);
+ btnUp.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ moveExtensionAction(-1);
+ }
+ });
btnUp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnUp.setText(Messages.ExternalInstallPage_btnUp_text);
btnDown = new Button(container, SWT.NONE);
+ btnDown.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ moveExtensionAction(1);
+ }
+ });
btnDown.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnDown.setText(Messages.ExternalInstallPage_btnDown_text);
Button btnRestoreDefault = new Button(container, SWT.NONE);
+ btnRestoreDefault.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ resetExtensionsAction();
+ }
+ });
btnRestoreDefault.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1));
btnRestoreDefault.setText(Messages.ExternalInstallPage_btnRestoreDefault_text);
@@ -246,24 +254,39 @@ public class MavenInstallationWizardPage extends WizardPage {
updateStatus();
}
+ protected void moveExtensionAction(int offset) {
+ int from = extensions.indexOf(getSelectedElement());
+ int to = Math.min(extensions.size() - 1, Math.max(0, from + offset));
+ Collections.swap(extensions, from, to);
+ treeViewerLibrariries.refresh();
+ }
+
+ protected void resetExtensionsAction() {
+ extensions.clear();
+ treeViewerLibrariries.refresh();
+ }
+
+ protected void removeExtensionAction() {
+ Object selection = getSelectedElement();
+ extensions.remove(selection);
+ treeViewerLibrariries.refresh();
+ }
+
protected void updateButtonsState() {
Object selection = getSelectedElement();
// can move/remove classpath entries only
- boolean editEnabled = selection instanceof ClasspathEntryNode;
+ boolean editEnabled = selection != null;
btnUp.setEnabled(editEnabled);
btnDown.setEnabled(editEnabled);
btnRemove.setEnabled(editEnabled);
-
- // add project requires insertion point
- btnAddProject.setEnabled(selection != null);
}
private Object getSelectedElement() {
return ((IStructuredSelection) treeViewerLibrariries.getSelection()).getFirstElement();
}
- protected void addProjectAction() {
+ protected void addProjectExtensionAction() {
List<Object> projects = new ArrayList<Object>();
for(IMavenProjectFacade facade : MavenPlugin.getMavenProjectRegistry().getProjects()) {
projects.add(facade.getProject());
@@ -274,17 +297,10 @@ public class MavenInstallationWizardPage extends WizardPage {
dialog.setHelpAvailable(false);
if(dialog.open() == Window.OK) {
Object insertionPoint = getSelectedElement();
- if(insertionPoint instanceof ClassRealmNode) {
- ClassRealmNode realm = (ClassRealmNode) insertionPoint;
+ if(insertionPoint == null || insertionPoint instanceof ClasspathEntry) {
+ int idx = Math.max(0, extensions.indexOf(insertionPoint));
for(Object object : dialog.getResult()) {
- realm.getClasspath().add(0, new ProjectEntryNode(realm, (IProject) object));
- }
- } else if(insertionPoint instanceof ClasspathEntryNode) {
- ClasspathEntryNode entry = (ClasspathEntryNode) insertionPoint;
- ClassRealmNode realm = entry.getRealm();
- int idx = realm.getIndex(entry);
- for(Object object : dialog.getResult()) {
- realm.getClasspath().add(idx, new ProjectEntryNode(realm, (IProject) object));
+ extensions.add(idx, new ProjectClasspathEntry(((IProject) object).getName()));
}
} else {
throw new IllegalStateException();
@@ -302,6 +318,9 @@ public class MavenInstallationWizardPage extends WizardPage {
return;
}
location.setText(dir);
+ if(name.getText().trim().isEmpty()) {
+ name.setText(new File(dir).getName());
+ }
}
private boolean isValidMavenInstall(String dir) {
@@ -346,6 +365,8 @@ public class MavenInstallationWizardPage extends WizardPage {
}
public AbstractMavenRuntime getResult() {
- return new MavenExternalRuntime(name.getText(), location.getText());
+ MavenExternalRuntime runtime = new MavenExternalRuntime(name.getText(), location.getText());
+ runtime.setExtensions(extensions);
+ return runtime;
}
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ProjectEntryNode.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ProjectEntryNode.java
deleted file mode 100644
index cec1e173..00000000
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ProjectEntryNode.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Takari, Inc.
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Takari, Inc. - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.m2e.core.ui.internal.preferences.launch;
-
-import org.eclipse.core.resources.IProject;
-
-
-public class ProjectEntryNode extends ClasspathEntryNode {
-
- private IProject project;
-
- public ProjectEntryNode(ClassRealmNode realm, IProject project) {
- super(realm);
- this.project = project;
- }
-
- @Override
- public String getName() {
- return project.getName();
- }
-}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntimeManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntimeManager.java
index 437c427b..0eb8df36 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntimeManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntimeManager.java
@@ -210,7 +210,10 @@ public class MavenRuntimeManager {
}
List<ClasspathEntry> result = new ArrayList<ClasspathEntry>();
for(String entry : string.split("\\|")) {
- result.add(ClasspathEntry.fromExternalForm(entry));
+ ClasspathEntry decoded = ClasspathEntry.fromExternalForm(entry);
+ if(decoded != null) {
+ result.add(decoded);
+ }
}
return result;
}
@@ -239,8 +242,9 @@ public class MavenRuntimeManager {
private AbstractMavenRuntime createRuntime(String name, Preferences preferences) {
String location = preferences.get("location", null);
- List<ClasspathEntry> extensions = decodeClasspath(preferences.get("extensions", null));
- return new MavenExternalRuntime(name, location);
+ MavenExternalRuntime runtime = new MavenExternalRuntime(name, location);
+ runtime.setExtensions(decodeClasspath(preferences.get("extensions", null)));
+ return runtime;
}
/**
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java
index 5c5d95c4..d091b65c 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java
@@ -246,6 +246,8 @@ public class Messages extends NLS {
public static String ProjectConversion_error_duplicate_conversion_participant;
+ public static String AbstractMavenRuntime_unknownProject;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/AbstractMavenRuntime.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/AbstractMavenRuntime.java
index f32de7ed..2f9d5e89 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/AbstractMavenRuntime.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/AbstractMavenRuntime.java
@@ -11,9 +11,25 @@
package org.eclipse.m2e.core.internal.launch;
+import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.embedder.IMavenLauncherConfiguration;
import org.eclipse.m2e.core.embedder.MavenRuntime;
+import org.eclipse.m2e.core.internal.IMavenConstants;
+import org.eclipse.m2e.core.internal.Messages;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.core.project.IMavenProjectRegistry;
/**
@@ -21,8 +37,14 @@ import org.eclipse.m2e.core.embedder.MavenRuntime;
*/
public abstract class AbstractMavenRuntime implements MavenRuntime {
+ private static final IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
+
+ private static final IMavenProjectRegistry registry = MavenPlugin.getMavenProjectRegistry();
+
private final String name;
+ private List<ClasspathEntry> extensions;
+
@Deprecated
protected AbstractMavenRuntime() {
this.name = null;
@@ -38,10 +60,38 @@ public abstract class AbstractMavenRuntime implements MavenRuntime {
}
public List<ClasspathEntry> getExtensions() {
- return null;
+ return extensions;
+ }
+
+ public void setExtensions(List<ClasspathEntry> extensions) {
+ this.extensions = extensions != null && !extensions.isEmpty() ? new ArrayList<ClasspathEntry>(extensions) : null;
}
public boolean isLegacy() {
return name == null;
}
+
+ protected void collectExtensions(IMavenLauncherConfiguration collector, IProgressMonitor monitor)
+ throws CoreException {
+ if(extensions != null) {
+ for(ClasspathEntry entry : extensions) {
+ if(entry instanceof ProjectClasspathEntry) {
+ collectProject(collector, (ProjectClasspathEntry) entry, monitor);
+ }
+ }
+ }
+ }
+
+ private void collectProject(IMavenLauncherConfiguration collector, ProjectClasspathEntry entry,
+ IProgressMonitor monitor) throws CoreException {
+ IProject project = workspace.getProject(entry.getProject());
+ IMavenProjectFacade facade = registry.create(project, monitor);
+ if(facade == null) {
+ throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, NLS.bind(
+ Messages.AbstractMavenRuntime_unknownProject, entry.getProject())));
+
+ }
+ collector.addProjectEntry(facade);
+ }
+
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/AbstractWorkspaceRuntime.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/AbstractWorkspaceRuntime.java
index 61986968..1c592add 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/AbstractWorkspaceRuntime.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/AbstractWorkspaceRuntime.java
@@ -109,6 +109,9 @@ public abstract class AbstractWorkspaceRuntime extends AbstractMavenRuntime {
//
collector.setMainType(getMainClass(), PLEXUS_CLASSWORLD_NAME);
collector.addRealm(PLEXUS_CLASSWORLD_NAME);
+
+ collectExtensions(collector, monitor);
+
//
// plexus.core is the current realm, and now we want the add the SLF4J loggging configuration if
// we have a verion>3.1.x Maven-like runtime
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/ClasspathEntry.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/ClasspathEntry.java
index 6572cca4..95bb8849 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/ClasspathEntry.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/ClasspathEntry.java
@@ -11,13 +11,23 @@
package org.eclipse.m2e.core.internal.launch;
+
+
/**
* @since 1.5
*/
public abstract class ClasspathEntry {
- public abstract String toExternalForm();
+ public String toExternalForm() {
+ if(this instanceof ProjectClasspathEntry) {
+ return "P/" + ((ProjectClasspathEntry) this).getProject();
+ }
+ throw new IllegalArgumentException();
+ }
public static ClasspathEntry fromExternalForm(String str) {
+ if(str.startsWith("P/")) {
+ return new ProjectClasspathEntry(str.substring(2));
+ }
return null;
}
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenEmbeddedRuntime.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenEmbeddedRuntime.java
index 6668e3fa..5f820a46 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenEmbeddedRuntime.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenEmbeddedRuntime.java
@@ -105,6 +105,7 @@ public class MavenEmbeddedRuntime extends AbstractMavenRuntime {
}
collector.addRealm(PLEXUS_CLASSWORLD_NAME);
+ collectExtensions(collector, monitor);
for(String entry : CLASSPATH) {
// https://issues.sonatype.org/browse/MNGECLIPSE-2507
if(!entry.contains("plexus-build-api")) {
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenExternalRuntime.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenExternalRuntime.java
index 47420626..88f4c5a9 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenExternalRuntime.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenExternalRuntime.java
@@ -81,13 +81,15 @@ public class MavenExternalRuntime extends AbstractMavenRuntime {
return new File(location, "bin/m2.conf"); //$NON-NLS-1$
}
- public void createLauncherConfiguration(final IMavenLauncherConfiguration collector, IProgressMonitor monitor)
+ public void createLauncherConfiguration(final IMavenLauncherConfiguration collector, final IProgressMonitor monitor)
throws CoreException {
collector.addRealm(IMavenLauncherConfiguration.LAUNCHER_REALM);
collector.addArchiveEntry(getLauncherClasspath());
ConfigurationHandler handler = new ConfigurationHandler() {
+ private String mainRealmName;
+
public void addImportFrom(String relamName, String importSpec) {
throw new UnsupportedOperationException(Messages.MavenExternalRuntime_exc_unsupported);
}
@@ -109,10 +111,21 @@ public class MavenExternalRuntime extends AbstractMavenRuntime {
}
public void addRealm(String realmName) {
+ if(mainRealmName == null) {
+ throw new IllegalStateException();
+ }
collector.addRealm(realmName);
+ if(mainRealmName.equals(realmName)) {
+ try {
+ collectExtensions(collector, monitor);
+ } catch(CoreException ex) {
+ throw new ExceptionWrapper(ex);
+ }
+ }
}
public void setAppMain(String mainClassName, String mainRealmName) {
+ this.mainRealmName = mainRealmName;
collector.setMainType(mainClassName, mainRealmName);
}
};
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ClasspathEntryNode.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/ProjectClasspathEntry.java
index efb4661d..e6eb231a 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/ClasspathEntryNode.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/ProjectClasspathEntry.java
@@ -9,19 +9,20 @@
* Takari, Inc. - initial API and implementation
*******************************************************************************/
-package org.eclipse.m2e.core.ui.internal.preferences.launch;
+package org.eclipse.m2e.core.internal.launch;
-public abstract class ClasspathEntryNode {
+/**
+ * @since 1.5
+ */
+public class ProjectClasspathEntry extends ClasspathEntry {
- private ClassRealmNode realm;
+ private String project;
- public ClasspathEntryNode(ClassRealmNode realm) {
- this.realm = realm;
+ public ProjectClasspathEntry(String project) {
+ this.project = project;
}
- public ClassRealmNode getRealm() {
- return this.realm;
+ public String getProject() {
+ return project;
}
-
- public abstract String getName();
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties
index 227ff9e7..b349539f 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties
@@ -1,4 +1,5 @@
AbstractLifecycleMapping_could_not_update_project_configuration=Could not update project {0} configuration
+AbstractMavenRuntime_unknownProject=Not a Maven project {0}
AbstractProjectConfigurator_error_missing_nature=Project does not have required nature
AbstractTransferListenerAdapter_4=0% {0}
AbstractTransferListenerAdapter_byte=B
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/MavenLaunchConstants.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/MavenLaunchConstants.java
index ad3d7547..7f1cc6e3 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/MavenLaunchConstants.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/actions/MavenLaunchConstants.java
@@ -70,9 +70,6 @@ public interface MavenLaunchConstants {
public final String ATTR_RUNTIME = "M2_RUNTIME"; //$NON-NLS-1$
- // hidden (for now) list of workspace components to be pushed into maven runtime
- public final String ATTR_FORCED_COMPONENTS_LIST = "M2_FORCED_COMPONENTS_LIST"; //$NON-NLS-1$
-
public final String ATTR_DISABLED_EXTENSIONS = "M2_DISABLED_EXTENSIONS";
public final String ATTR_THREADS = "M2_THREADS"; //$NON-NLS-1$
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchUtils.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchUtils.java
index 7b3c231c..3b625bb5 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchUtils.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchUtils.java
@@ -14,14 +14,9 @@ package org.eclipse.m2e.internal.launch;
import java.io.File;
import java.net.URI;
import java.net.URL;
-import java.util.ArrayList;
import java.util.List;
import org.osgi.framework.Bundle;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.ibm.icu.util.StringTokenizer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
@@ -30,16 +25,10 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.osgi.util.NLS;
-import org.apache.maven.artifact.Artifact;
-
import org.eclipse.m2e.actions.MavenLaunchConstants;
import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.embedder.IMaven;
-import org.eclipse.m2e.core.embedder.IMavenLauncherConfiguration;
import org.eclipse.m2e.core.embedder.MavenRuntime;
import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
-import org.eclipse.m2e.core.project.IMavenProjectFacade;
-import org.eclipse.m2e.core.project.IMavenProjectRegistry;
/**
@@ -48,7 +37,6 @@ import org.eclipse.m2e.core.project.IMavenProjectRegistry;
* @author Igor Fedorenko
*/
public class MavenLaunchUtils {
- private static final Logger log = LoggerFactory.getLogger(MavenLaunchUtils.class);
public static MavenRuntime getMavenRuntime(ILaunchConfiguration configuration) throws CoreException {
MavenRuntimeManager runtimeManager = MavenPlugin.getMavenRuntimeManager();
@@ -89,42 +77,6 @@ public class MavenLaunchUtils {
}
}
- public static void addUserComponents(ILaunchConfiguration configuration, IMavenLauncherConfiguration collector)
- throws CoreException {
- List<String> list = configuration.getAttribute(MavenLaunchConstants.ATTR_FORCED_COMPONENTS_LIST,
- new ArrayList<String>());
- if(list == null) {
- return;
- }
-
- IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
- IMaven maven = MavenPlugin.getMaven();
- for(String gav : list) {
- // groupId:artifactId:version
- StringTokenizer st = new StringTokenizer(gav, ":"); //$NON-NLS-1$
- String groupId = st.nextToken();
- String artifactId = st.nextToken();
- String version = st.nextToken();
-
- IMavenProjectFacade facade = projectManager.getMavenProject(groupId, artifactId, version);
-
- if(facade != null) {
- collector.addProjectEntry(facade);
- } else {
- String name = groupId + ":" + artifactId + ":" + version; //$NON-NLS-1$ //$NON-NLS-2$
- try {
- Artifact artifact = maven.resolve(groupId, artifactId, version, "jar", null, null, null); //$NON-NLS-1$
- File file = artifact.getFile();
- if(file != null) {
- collector.addArchiveEntry(file.getAbsolutePath());
- }
- } catch(CoreException ex) {
- log.error("Artifact not found " + name, ex);
- }
- }
- }
- }
-
/**
* @since 1.4
*/
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLauncherConfigurationHandler.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLauncherConfigurationHandler.java
index 1b5cc1ec..91bcf3a1 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLauncherConfigurationHandler.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLauncherConfigurationHandler.java
@@ -48,14 +48,23 @@ public class MavenLauncherConfigurationHandler implements IMavenLauncherConfigur
private LinkedHashMap<String, List<String>> realms = new LinkedHashMap<String, List<String>>();
- private List<String> forcedEntries = new ArrayList<String>();
-
- private List<String> curEntries = forcedEntries;
+ private List<String> curEntries;
public void addArchiveEntry(String entry) {
+ if(curEntries == null) {
+ throw new IllegalStateException();
+ }
curEntries.add(entry);
}
+ public void forceArchiveEntry(String entry) {
+ List<String> realm = realms.get(mainRealm);
+ if(realm == null) {
+ throw new IllegalStateException();
+ }
+ realm.add(0, entry);
+ }
+
public void addProjectEntry(IMavenProjectFacade facade) {
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFolder output = root.getFolder(facade.getOutputLocation());
@@ -105,11 +114,6 @@ public class MavenLauncherConfigurationHandler implements IMavenLauncherConfigur
continue;
}
out.write(NLS.bind("[{0}]\n", realm.getKey()));
- if(mainRealm.equals(realm.getKey())) {
- for(String entry : forcedEntries) {
- out.write(NLS.bind("load {0}\n", entry));
- }
- }
for(String entry : realm.getValue()) {
out.write(NLS.bind("load {0}\n", entry));
}
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenRuntimeLaunchSupport.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenRuntimeLaunchSupport.java
index 2782e976..5779c3c7 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenRuntimeLaunchSupport.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenRuntimeLaunchSupport.java
@@ -112,11 +112,10 @@ public class MavenRuntimeLaunchSupport {
boolean resolveWorkspaceArtifacts = configuration.getAttribute(ATTR_WORKSPACE_RESOLUTION, false);
MavenLauncherConfigurationHandler cwconf = new MavenLauncherConfigurationHandler();
+ runtime.createLauncherConfiguration(cwconf, monitor);
if(resolveWorkspaceArtifacts) {
- cwconf.addArchiveEntry(MavenLaunchUtils.getCliResolver(runtime));
+ cwconf.forceArchiveEntry(MavenLaunchUtils.getCliResolver(runtime));
}
- MavenLaunchUtils.addUserComponents(configuration, cwconf);
- runtime.createLauncherConfiguration(cwconf, monitor);
File cwconfFile;
try {
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenSourcePathComputer.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenSourcePathComputer.java
index 7475edb7..6050ccc9 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenSourcePathComputer.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenSourcePathComputer.java
@@ -90,7 +90,6 @@ public class MavenSourcePathComputer implements ISourcePathComputer {
};
collector.addArchiveEntry(MavenLaunchUtils.getCliResolver(runtime));
- MavenLaunchUtils.addUserComponents(configuration, collector);
runtime.createLauncherConfiguration(collector, monitor);
IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath( //

Back to the top