Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2014-04-22 18:13:56 -0400
committerIgor Fedorenko2014-04-23 07:19:35 -0400
commit67fce5dbb00d72f2d951a4f61b0c73631b52f080 (patch)
treed32f4e573bb04c9d0d0517796ab76f678a586149
parentcc933903cb2f37a855f35ddea630a3bab373e878 (diff)
downloadm2e-core-67fce5dbb00d72f2d951a4f61b0c73631b52f080.tar.gz
m2e-core-67fce5dbb00d72f2d951a4f61b0c73631b52f080.tar.xz
m2e-core-67fce5dbb00d72f2d951a4f61b0c73631b52f080.zip
deprecated MavenRuntimeManager and friends
At very least this API was misplaced, it should have been exposed from o.e.m2e.launch bundle, not from the core. More realistically, all maven launch support should be moved to o.e.m2e.launch implementation and exposed as API when we get at least few real consumers. Change-Id: I6250d5c8d1a05801ca7dbdc2e628906c809b3441 Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizard.java9
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java44
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java6
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMavenLauncherConfiguration.java1
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntime.java7
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntimeManager.java238
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java8
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/AbstractMavenRuntime.java12
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/DefaultWorkspaceRuntime.java5
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenEmbeddedRuntime.java6
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenExternalRuntime.java1
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenRuntimeManagerImpl.java242
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenWorkspaceRuntime.java4
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceConstants.java6
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchUtils.java15
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenRuntimeLaunchSupport.java11
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenSourcePathComputer.java5
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java31
18 files changed, 355 insertions, 296 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizard.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizard.java
index d2e45686..6f8bac37 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizard.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationWizard.java
@@ -15,7 +15,6 @@ import java.util.Set;
import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.m2e.core.embedder.MavenRuntime;
import org.eclipse.m2e.core.internal.launch.AbstractMavenRuntime;
import org.eclipse.m2e.core.ui.internal.Messages;
@@ -25,15 +24,15 @@ public class MavenInstallationWizard extends Wizard {
private final MavenInstallationWizardPage runtimePage;
- private MavenRuntime result;
+ private AbstractMavenRuntime result;
public MavenInstallationWizard(Set<String> names) {
this.runtimePage = new MavenInstallationWizardPage(null, names);
setWindowTitle(Messages.MavenInstallationWizard_titleNewInstallation);
}
- public MavenInstallationWizard(MavenRuntime original, Set<String> names) {
- this.runtimePage = new MavenInstallationWizardPage((AbstractMavenRuntime) original, names);
+ public MavenInstallationWizard(AbstractMavenRuntime original, Set<String> names) {
+ this.runtimePage = new MavenInstallationWizardPage(original, names);
setWindowTitle(Messages.MavenInstallationWizard_titleAddInstallation);
}
@@ -48,7 +47,7 @@ public class MavenInstallationWizard extends Wizard {
return true;
}
- public MavenRuntime getResult() {
+ public AbstractMavenRuntime getResult() {
return result;
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java
index 54dffdc8..147093bd 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java
@@ -51,9 +51,9 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
-import org.eclipse.m2e.core.embedder.MavenRuntime;
-import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.launch.AbstractMavenRuntime;
+import org.eclipse.m2e.core.internal.launch.MavenRuntimeManagerImpl;
import org.eclipse.m2e.core.ui.internal.Messages;
@@ -65,7 +65,7 @@ import org.eclipse.m2e.core.ui.internal.Messages;
@SuppressWarnings("restriction")
public class MavenInstallationsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
- final MavenRuntimeManager runtimeManager;
+ final MavenRuntimeManagerImpl runtimeManager;
final IMavenConfiguration mavenConfiguration;
@@ -73,14 +73,14 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
String defaultRuntime;
- List<MavenRuntime> runtimes;
+ List<AbstractMavenRuntime> runtimes;
CheckboxTableViewer runtimesViewer;
public MavenInstallationsPreferencePage() {
setTitle(Messages.MavenInstallationsPreferencePage_title);
- this.runtimeManager = MavenPlugin.getMavenRuntimeManager();
+ this.runtimeManager = MavenPluginActivator.getDefault().getMavenRuntimeManager();
this.mavenConfiguration = MavenPlugin.getMavenConfiguration();
this.maven = MavenPlugin.getMaven();
}
@@ -133,12 +133,12 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
return composite;
}
- private MavenRuntime getDefaultRuntime() {
- MavenRuntime embedded = null;
- for(MavenRuntime runtime : runtimes) {
+ private AbstractMavenRuntime getDefaultRuntime() {
+ AbstractMavenRuntime embedded = null;
+ for(AbstractMavenRuntime runtime : runtimes) {
if(defaultRuntime.equals(runtime.getName())) {
return runtime;
- } else if(MavenRuntimeManager.EMBEDDED.equals(runtime.getName())) {
+ } else if(MavenRuntimeManagerImpl.EMBEDDED.equals(runtime.getName())) {
embedded = runtime;
}
}
@@ -150,7 +150,7 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
Object[] checkedElements = runtimesViewer.getCheckedElements();
if(checkedElements == null || checkedElements.length == 0) {
- MavenRuntime runtime = getDefaultRuntime();
+ AbstractMavenRuntime runtime = getDefaultRuntime();
runtimesViewer.setChecked(runtime, true);
defaultRuntime = runtime.getName();
}
@@ -160,9 +160,9 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
}
}
- protected MavenRuntime getSelectedMavenRuntime() {
+ protected AbstractMavenRuntime getSelectedMavenRuntime() {
IStructuredSelection sel = (IStructuredSelection) runtimesViewer.getSelection();
- return (MavenRuntime) sel.getFirstElement();
+ return (AbstractMavenRuntime) sel.getFirstElement();
}
private void createTable(Composite composite) {
@@ -176,7 +176,7 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
if(input instanceof List<?>) {
List<?> list = (List<?>) input;
if(list.size() > 0) {
- return list.toArray(new MavenRuntime[list.size()]);
+ return list.toArray(new AbstractMavenRuntime[list.size()]);
}
}
return new Object[0];
@@ -226,11 +226,11 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
editButton.setText(Messages.MavenInstallationsPreferencePage_btnEdit);
editButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- MavenRuntime runtime = getSelectedMavenRuntime();
+ AbstractMavenRuntime runtime = getSelectedMavenRuntime();
MavenInstallationWizard wizard = new MavenInstallationWizard(runtime, getForbiddenNames(runtime));
WizardDialog dialog = new WizardDialog(getShell(), wizard);
if(dialog.open() == Window.OK) {
- MavenRuntime updatedRuntime = wizard.getResult();
+ AbstractMavenRuntime updatedRuntime = wizard.getResult();
for(int i = 0; i < runtimes.size(); i++ ) {
if(runtime == runtimes.get(i)) {
runtimes.set(i, updatedRuntime);
@@ -248,7 +248,7 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
removeButton.setText(Messages.MavenInstallationsPreferencePage_btnRemove);
removeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- MavenRuntime runtime = getSelectedMavenRuntime();
+ AbstractMavenRuntime runtime = getSelectedMavenRuntime();
runtimes.remove(runtime);
refreshRuntimesViewer();
}
@@ -257,7 +257,7 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
runtimesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
if(runtimesViewer.getSelection() instanceof IStructuredSelection) {
- MavenRuntime runtime = getSelectedMavenRuntime();
+ AbstractMavenRuntime runtime = getSelectedMavenRuntime();
boolean isEnabled = runtime != null && runtime.isEditable();
removeButton.setEnabled(isEnabled);
editButton.setEnabled(isEnabled);
@@ -267,7 +267,7 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
runtimesViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
- setCheckedRuntime((MavenRuntime) event.getElement());
+ setCheckedRuntime((AbstractMavenRuntime) event.getElement());
}
});
Label noteLabel = new Label(composite, SWT.WRAP);
@@ -278,9 +278,9 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
noteLabel.setText(Messages.MavenInstallationsPreferencePage_lblNote);
}
- protected Set<String> getForbiddenNames(MavenRuntime runtime) {
+ protected Set<String> getForbiddenNames(AbstractMavenRuntime runtime) {
Set<String> names = new HashSet<String>();
- for(MavenRuntime other : runtimes) {
+ for(AbstractMavenRuntime other : runtimes) {
if(other != runtime) {
names.add(other.getName());
}
@@ -288,7 +288,7 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
return names;
}
- protected void setCheckedRuntime(MavenRuntime runtime) {
+ protected void setCheckedRuntime(AbstractMavenRuntime runtime) {
runtimesViewer.setAllChecked(false);
if(runtime == null || !runtime.isAvailable()) {
runtime = getDefaultRuntime();
@@ -328,7 +328,7 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
}
public Color getForeground(Object element) {
- MavenRuntime runtime = (MavenRuntime) element;
+ AbstractMavenRuntime runtime = (AbstractMavenRuntime) element;
if(!runtime.isEditable()) {
return Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY);
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java
index df93ebbd..0f853667 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java
@@ -62,8 +62,12 @@ public final class MavenPlugin {
return MavenPluginActivator.getDefault().getMavenConfiguration();
}
+ /**
+ * @deprecated as of version 1.5, m2e does not provide API to access or configure Maven Installations
+ */
+ @SuppressWarnings("deprecation")
public static MavenRuntimeManager getMavenRuntimeManager() {
- return MavenPluginActivator.getDefault().getMavenRuntimeManager();
+ return new MavenRuntimeManager(MavenPluginActivator.getDefault().getMavenRuntimeManager());
}
public static MavenModelManager getMavenModelManager() {
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMavenLauncherConfiguration.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMavenLauncherConfiguration.java
index 538be2db..8e9d89f1 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMavenLauncherConfiguration.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMavenLauncherConfiguration.java
@@ -21,6 +21,7 @@ import org.eclipse.m2e.core.project.IMavenProjectFacade;
*
* @author Igor Fedorenko
* @see MavenRuntime#createLauncherConfiguration
+ * @deprecated as of version 1.5, m2e does not provide API to access or configure Maven Installations
*/
public interface IMavenLauncherConfiguration {
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntime.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntime.java
index c4bad9a8..83412932 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntime.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntime.java
@@ -21,7 +21,9 @@ import org.eclipse.core.runtime.IProgressMonitor;
* @author Eugene Kuleshov
* @author Igor Fedorenko
* @noimplement This interface is not intended to be implemented by clients.
+ * @deprecated as of version 1.5, m2e does not provide API to access or configure Maven Installations
*/
+@SuppressWarnings("deprecation")
public interface MavenRuntime {
public abstract boolean isEditable();
@@ -33,11 +35,6 @@ public interface MavenRuntime {
public abstract void createLauncherConfiguration(IMavenLauncherConfiguration collector, IProgressMonitor monitor)
throws CoreException;
- /**
- * @since 1.5
- */
- public abstract String getName();
-
public abstract String getLocation();
public abstract String getSettings();
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 69e06b44..ab426419 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
@@ -12,55 +12,34 @@
package org.eclipse.m2e.core.embedder;
import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IPreferencesService;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-
-import org.eclipse.m2e.core.internal.IMavenConstants;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.launch.AbstractMavenRuntime;
-import org.eclipse.m2e.core.internal.launch.ClasspathEntry;
-import org.eclipse.m2e.core.internal.launch.DefaultWorkspaceRuntime;
-import org.eclipse.m2e.core.internal.launch.MavenEmbeddedRuntime;
import org.eclipse.m2e.core.internal.launch.MavenExternalRuntime;
-import org.eclipse.m2e.core.internal.launch.MavenWorkspaceRuntime;
-import org.eclipse.m2e.core.internal.preferences.MavenPreferenceConstants;
+import org.eclipse.m2e.core.internal.launch.MavenRuntimeManagerImpl;
/**
* Maven runtime manager
*
+ * @deprecated as of version 1.5, m2e does not provide API to access or configure Maven Installations
* @author Eugene Kuleshov
* @author Jason van Zyl
*/
+@SuppressWarnings("deprecation")
public class MavenRuntimeManager {
- public static final String DEFAULT = "DEFAULT"; //$NON-NLS-1$
-
- public static final String EMBEDDED = "EMBEDDED"; //$NON-NLS-1$
-
- public static final String WORKSPACE = "WORKSPACE"; //$NON-NLS-1$
+ public static final String DEFAULT = MavenRuntimeManagerImpl.DEFAULT;
- public static final String EXTERNAL = "EXTERNAL"; //$NON-NLS-1$
+ public static final String EMBEDDED = MavenRuntimeManagerImpl.EMBEDDED;
- private final IEclipsePreferences[] preferencesLookup = new IEclipsePreferences[2];
+ public static final String WORKSPACE = MavenRuntimeManagerImpl.WORKSPACE;
- private final IPreferencesService preferenceStore;
+ private final MavenRuntimeManagerImpl impl;
- public MavenRuntimeManager() {
- this.preferenceStore = Platform.getPreferencesService();
- this.preferencesLookup[0] = InstanceScope.INSTANCE.getNode(IMavenConstants.PLUGIN_ID);
- this.preferencesLookup[1] = DefaultScope.INSTANCE.getNode(IMavenConstants.PLUGIN_ID);
+ public MavenRuntimeManager(MavenRuntimeManagerImpl impl) {
+ this.impl = impl;
}
/**
@@ -72,27 +51,18 @@ public class MavenRuntimeManager {
/**
* @deprecated this method does nothing
*/
- @Deprecated
public void setWorkspaceRuntime(MavenRuntime workspaceRuntime) {
}
public MavenRuntime getDefaultRuntime() {
- String selected = preferenceStore.get(MavenPreferenceConstants.P_DEFAULT_RUNTIME, null, preferencesLookup);
- if(selected == null) {
- return new MavenEmbeddedRuntime();
- }
- MavenRuntime runtime = getRuntimeByName(selected);
- return runtime != null && runtime.isAvailable() ? runtime : new MavenEmbeddedRuntime();
+ return impl.getDefaultRuntime();
}
- /**
- * @deprecated use {@link #getRuntimeByName(String)}
- */
public MavenRuntime getRuntime(String location) {
if(location == null || location.length() == 0 || DEFAULT.equals(location)) {
return getDefaultRuntime();
}
- for(MavenRuntime runtime : getRuntimes().values()) {
+ for(MavenRuntime runtime : impl.getRuntimes().values()) {
if(location.equals(runtime.getLocation())) {
return runtime;
}
@@ -101,200 +71,36 @@ public class MavenRuntimeManager {
return null;
}
- /**
- * @since 1.5
- */
- public MavenRuntime getRuntimeByName(String name) {
- return getRuntimes().get(name);
- }
-
public List<MavenRuntime> getMavenRuntimes() {
- List<MavenRuntime> mavenRuntimes = new ArrayList<MavenRuntime>();
- for(MavenRuntime mavenRuntime : getRuntimes().values()) {
- if(mavenRuntime.isAvailable()) {
- mavenRuntimes.add(mavenRuntime);
- }
+ List<MavenRuntime> result = new ArrayList<MavenRuntime>();
+ for(AbstractMavenRuntime runtime : impl.getMavenRuntimes()) {
+ result.add(runtime);
}
- return mavenRuntimes;
- }
-
- /**
- * @param available is {@code true} only available runtimes are returned, all runtimes are returned if {@code false}
- * @since 1.5
- */
- public List<MavenRuntime> getMavenRuntimes(boolean available) {
- List<MavenRuntime> mavenRuntimes = new ArrayList<MavenRuntime>();
- for(MavenRuntime mavenRuntime : getRuntimes().values()) {
- if(!available || mavenRuntime.isAvailable()) {
- mavenRuntimes.add(mavenRuntime);
- }
- }
- return mavenRuntimes;
+ return result;
}
public void reset() {
- preferencesLookup[0].remove(MavenPreferenceConstants.P_RUNTIMES);
- preferencesLookup[0].remove(MavenPreferenceConstants.P_DEFAULT_RUNTIME);
- removeRuntimePreferences();
- flush();
+ impl.reset();
}
public void setDefaultRuntime(MavenRuntime runtime) {
- if(runtime == null) {
- preferencesLookup[0].remove(MavenPreferenceConstants.P_DEFAULT_RUNTIME);
- } else {
- preferencesLookup[0].put(MavenPreferenceConstants.P_DEFAULT_RUNTIME, runtime.getName());
- }
- flush();
- }
-
- private void flush() {
- try {
- preferencesLookup[0].flush();
- } catch(BackingStoreException ex) {
- // TODO do nothing
- }
+ impl.setDefaultRuntime((AbstractMavenRuntime) runtime);
}
public void setRuntimes(List<MavenRuntime> runtimes) {
- removeRuntimePreferences();
- Set<String> names = new HashSet<String>();
- StringBuilder sb = new StringBuilder();
+ List<AbstractMavenRuntime> internal = new ArrayList<AbstractMavenRuntime>();
for(MavenRuntime runtime : runtimes) {
- if(!names.add(runtime.getName())) {
- throw new IllegalArgumentException();
- }
- if(runtime.isEditable()) {
- AbstractMavenRuntime impl = (AbstractMavenRuntime) runtime;
- if(sb.length() > 0) {
- sb.append('|');
- }
- sb.append(runtime.getName());
- if(!impl.isLegacy()) {
- Preferences runtimeNode = getRuntimePreferences(runtime.getName(), true);
- runtimeNode.put("type", getRuntimeType(runtime));
- runtimeNode.put("location", runtime.getLocation());
- String extensions = encodeClasspath(impl.getExtensions());
- if(extensions != null) {
- runtimeNode.put("extensions", extensions);
- } else {
- runtimeNode.remove("extensions");
- }
- }
- }
+ internal.add((AbstractMavenRuntime) runtime);
}
- preferencesLookup[0].put(MavenPreferenceConstants.P_RUNTIMES, sb.toString());
- flush();
+ impl.setRuntimes(internal);
}
- private void removeRuntimePreferences() {
- try {
- if(preferencesLookup[0].nodeExists(MavenPreferenceConstants.P_RUNTIMES_NODE)) {
- preferencesLookup[0].node(MavenPreferenceConstants.P_RUNTIMES_NODE).removeNode();
- }
- } catch(BackingStoreException ex) {
- // assume the node does not exist
- }
- }
-
- private String getRuntimeType(MavenRuntime runtime) {
- if(runtime instanceof MavenExternalRuntime) {
- return EXTERNAL;
- } else if(runtime instanceof MavenWorkspaceRuntime) {
- return WORKSPACE;
- }
- throw new IllegalArgumentException();
- }
-
- private Preferences getRuntimePreferences(String name, boolean create) {
- Preferences runtimesNode = preferencesLookup[0].node(MavenPreferenceConstants.P_RUNTIMES_NODE);
- try {
- if(runtimesNode.nodeExists(name) || create) {
- return runtimesNode.node(name);
- }
- } catch(BackingStoreException ex) {
- // assume the node does not exist
- }
- return null;
- }
-
- private String encodeClasspath(List<ClasspathEntry> classpath) {
- if(classpath == null || classpath.isEmpty()) {
- return null;
- }
- StringBuilder sb = new StringBuilder();
- for(ClasspathEntry cpe : classpath) {
- if(sb.length() > 0) {
- sb.append('|');
- }
- sb.append(cpe.toExternalForm());
- }
- return sb.toString();
- }
-
- private List<ClasspathEntry> decodeClasspath(String string) {
- if(string == null || string.isEmpty()) {
- return null;
- }
- List<ClasspathEntry> result = new ArrayList<ClasspathEntry>();
- for(String entry : string.split("\\|")) {
- ClasspathEntry decoded = ClasspathEntry.fromExternalForm(entry);
- if(decoded != null) {
- result.add(decoded);
- }
- }
- return result;
- }
-
- private Map<String, AbstractMavenRuntime> getRuntimes() {
- Map<String, AbstractMavenRuntime> runtimes = new LinkedHashMap<String, AbstractMavenRuntime>();
- runtimes.put(EMBEDDED, new MavenEmbeddedRuntime());
- runtimes.put(WORKSPACE, new DefaultWorkspaceRuntime());
-
- String runtimesPreference = preferenceStore.get(MavenPreferenceConstants.P_RUNTIMES, null, preferencesLookup);
- if(runtimesPreference != null && runtimesPreference.length() > 0) {
- for(String name : runtimesPreference.split("\\|")) { //$NON-NLS-1$
- Preferences preferences = getRuntimePreferences(name, false);
- AbstractMavenRuntime runtime;
- if(preferences == null) {
- runtime = (AbstractMavenRuntime) createExternalRuntime(name);
- } else {
- runtime = createRuntime(name, preferences);
- }
- runtimes.put(runtime.getName(), runtime);
- }
- }
-
- return runtimes;
- }
-
- private AbstractMavenRuntime createRuntime(String name, Preferences preferences) {
- String location = preferences.get("location", null);
- String type = preferences.get("type", EXTERNAL);
- AbstractMavenRuntime runtime;
- if(WORKSPACE.equals(type)) {
- runtime = new MavenWorkspaceRuntime(name);
- } else {
- runtime = new MavenExternalRuntime(name, location);
- }
- runtime.setExtensions(decodeClasspath(preferences.get("extensions", null)));
- return runtime;
- }
-
- /**
- * @deprecated as of version 1.5, m2e does not provide public API to create MavenRuntime instances
- */
public static MavenRuntime createExternalRuntime(String location) {
return new MavenExternalRuntime(location);
}
- /**
- * @deprecated global setting file is only used to determine localRepository location, which does not make much sense
- */
public String getGlobalSettingsFile() {
- String globalSettings = preferenceStore.get(MavenPreferenceConstants.P_GLOBAL_SETTINGS_FILE, null,
- preferencesLookup);
- return globalSettings.trim().length() == 0 ? null : globalSettings;
+ return MavenPluginActivator.getDefault().getMavenConfiguration().getGlobalSettingsFile();
}
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java
index 0f9a095a..82207689 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java
@@ -59,7 +59,6 @@ import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
import org.eclipse.m2e.core.embedder.IMavenExecutionContext;
import org.eclipse.m2e.core.embedder.MavenModelManager;
-import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
import org.eclipse.m2e.core.internal.archetype.ArchetypeCatalogFactory;
import org.eclipse.m2e.core.internal.archetype.ArchetypeManager;
import org.eclipse.m2e.core.internal.embedder.MavenImpl;
@@ -67,6 +66,7 @@ import org.eclipse.m2e.core.internal.index.filter.ArtifactFilterManager;
import org.eclipse.m2e.core.internal.index.nexus.IndexesExtensionReader;
import org.eclipse.m2e.core.internal.index.nexus.IndexingTransferListener;
import org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager;
+import org.eclipse.m2e.core.internal.launch.MavenRuntimeManagerImpl;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory;
import org.eclipse.m2e.core.internal.markers.IMavenMarkerManager;
import org.eclipse.m2e.core.internal.markers.MavenMarkerManager;
@@ -109,7 +109,7 @@ public class MavenPluginActivator extends Plugin {
private MavenProjectManager projectManager;
- private MavenRuntimeManager runtimeManager;
+ private MavenRuntimeManagerImpl runtimeManager;
private ProjectConfigurationManager configurationManager;
@@ -224,7 +224,7 @@ public class MavenPluginActivator extends Plugin {
this.modelManager = new MavenModelManager(maven, projectManager);
- this.runtimeManager = new MavenRuntimeManager();
+ this.runtimeManager = new MavenRuntimeManagerImpl();
this.configurationManager = new ProjectConfigurationManager(maven, managerImpl, modelManager, mavenMarkerManager,
mavenConfiguration);
@@ -347,7 +347,7 @@ public class MavenPluginActivator extends Plugin {
return this.indexManager;
}
- public MavenRuntimeManager getMavenRuntimeManager() {
+ public MavenRuntimeManagerImpl getMavenRuntimeManager() {
return this.runtimeManager;
}
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 7d6742c5..214c8143 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
@@ -35,6 +35,7 @@ import org.eclipse.m2e.core.project.IMavenProjectRegistry;
/**
* @since 1.5
*/
+@SuppressWarnings("deprecation")
public abstract class AbstractMavenRuntime implements MavenRuntime {
private static final IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
@@ -54,7 +55,6 @@ public abstract class AbstractMavenRuntime implements MavenRuntime {
this.name = name;
}
- @Override
public String getName() {
return name != null ? name : getLocation();
}
@@ -105,4 +105,14 @@ public abstract class AbstractMavenRuntime implements MavenRuntime {
return getName().hashCode();
}
+ public abstract void createLauncherConfiguration(IMavenLauncherConfiguration collector, IProgressMonitor monitor)
+ throws CoreException;
+
+ public abstract String getLocation();
+
+ public abstract boolean isAvailable();
+
+ public abstract boolean isEditable();
+
+ public abstract String getVersion();
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/DefaultWorkspaceRuntime.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/DefaultWorkspaceRuntime.java
index cf306811..e01d3bf3 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/DefaultWorkspaceRuntime.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/DefaultWorkspaceRuntime.java
@@ -11,16 +11,13 @@
package org.eclipse.m2e.core.internal.launch;
-import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
-
-
/**
* @since 1.5
*/
public class DefaultWorkspaceRuntime extends MavenWorkspaceRuntime {
public DefaultWorkspaceRuntime() {
- super(MavenRuntimeManager.WORKSPACE);
+ super(MavenRuntimeManagerImpl.WORKSPACE);
}
public boolean isEditable() {
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 2c9da47f..4eae036c 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
@@ -40,7 +40,6 @@ import org.eclipse.osgi.util.ManifestElement;
import org.codehaus.plexus.util.IOUtil;
import org.eclipse.m2e.core.embedder.IMavenLauncherConfiguration;
-import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
import org.eclipse.m2e.core.internal.Bundles;
import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.Messages;
@@ -53,6 +52,7 @@ import org.eclipse.m2e.core.internal.e44.DevClassPathHelper;
* @author Eugene Kuleshov
* @author Igor Fedorenko
*/
+@SuppressWarnings("deprecation")
public class MavenEmbeddedRuntime extends AbstractMavenRuntime {
private static final String MAVEN_CORE_POM_PROPERTIES = "META-INF/maven/org.apache.maven/maven-core/pom.properties"; //$NON-NLS-1$
@@ -74,7 +74,7 @@ public class MavenEmbeddedRuntime extends AbstractMavenRuntime {
private static final Bundle m2eCore = MavenPluginActivator.getDefault().getBundle();
public MavenEmbeddedRuntime() {
- super(MavenRuntimeManager.EMBEDDED);
+ super(MavenRuntimeManagerImpl.EMBEDDED);
}
public boolean isEditable() {
@@ -82,7 +82,7 @@ public class MavenEmbeddedRuntime extends AbstractMavenRuntime {
}
public String getLocation() {
- return MavenRuntimeManager.EMBEDDED;
+ return MavenRuntimeManagerImpl.EMBEDDED;
}
public String getSettings() {
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 c12cc42b..bf2c54a9 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
@@ -41,6 +41,7 @@ import org.eclipse.m2e.core.internal.Messages;
* @author Eugene Kuleshov
* @author Igor Fedorenko
*/
+@SuppressWarnings("deprecation")
public class MavenExternalRuntime extends AbstractMavenRuntime {
private static final Logger log = LoggerFactory.getLogger(MavenExternalRuntime.class);
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenRuntimeManagerImpl.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenRuntimeManagerImpl.java
new file mode 100644
index 00000000..3cdede27
--- /dev/null
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenRuntimeManagerImpl.java
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * 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.internal.launch;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+
+import org.eclipse.m2e.core.internal.IMavenConstants;
+import org.eclipse.m2e.core.internal.preferences.MavenPreferenceConstants;
+
+
+/**
+ * @since 1.5
+ */
+public class MavenRuntimeManagerImpl {
+ public static final String DEFAULT = "DEFAULT"; //$NON-NLS-1$
+
+ public static final String EMBEDDED = "EMBEDDED"; //$NON-NLS-1$
+
+ public static final String WORKSPACE = "WORKSPACE"; //$NON-NLS-1$
+
+ public static final String EXTERNAL = "EXTERNAL"; //$NON-NLS-1$
+
+ private final IEclipsePreferences[] preferencesLookup = new IEclipsePreferences[2];
+
+ private final IPreferencesService preferenceStore;
+
+ public MavenRuntimeManagerImpl() {
+ this.preferenceStore = Platform.getPreferencesService();
+ this.preferencesLookup[0] = InstanceScope.INSTANCE.getNode(IMavenConstants.PLUGIN_ID);
+ this.preferencesLookup[1] = DefaultScope.INSTANCE.getNode(IMavenConstants.PLUGIN_ID);
+ }
+
+ public AbstractMavenRuntime getDefaultRuntime() {
+ String selected = preferenceStore.get(MavenPreferenceConstants.P_DEFAULT_RUNTIME, null, preferencesLookup);
+ if(selected == null) {
+ return new MavenEmbeddedRuntime();
+ }
+ AbstractMavenRuntime runtime = getRuntimeByName(selected);
+ return runtime != null && runtime.isAvailable() ? runtime : new MavenEmbeddedRuntime();
+ }
+
+ public AbstractMavenRuntime getRuntimeByName(String name) {
+ return getRuntimes().get(name);
+ }
+
+ public List<AbstractMavenRuntime> getMavenRuntimes() {
+ List<AbstractMavenRuntime> mavenRuntimes = new ArrayList<AbstractMavenRuntime>();
+ for(AbstractMavenRuntime mavenRuntime : getRuntimes().values()) {
+ if(mavenRuntime.isAvailable()) {
+ mavenRuntimes.add(mavenRuntime);
+ }
+ }
+ return mavenRuntimes;
+ }
+
+ /**
+ * @param available is {@code true} only available runtimes are returned, all runtimes are returned if {@code false}
+ * @since 1.5
+ */
+ public List<AbstractMavenRuntime> getMavenRuntimes(boolean available) {
+ List<AbstractMavenRuntime> mavenRuntimes = new ArrayList<AbstractMavenRuntime>();
+ for(AbstractMavenRuntime mavenRuntime : getRuntimes().values()) {
+ if(!available || mavenRuntime.isAvailable()) {
+ mavenRuntimes.add(mavenRuntime);
+ }
+ }
+ return mavenRuntimes;
+ }
+
+ public void reset() {
+ preferencesLookup[0].remove(MavenPreferenceConstants.P_RUNTIMES);
+ preferencesLookup[0].remove(MavenPreferenceConstants.P_DEFAULT_RUNTIME);
+ removeRuntimePreferences();
+ flush();
+ }
+
+ public void setDefaultRuntime(AbstractMavenRuntime runtime) {
+ if(runtime == null) {
+ preferencesLookup[0].remove(MavenPreferenceConstants.P_DEFAULT_RUNTIME);
+ } else {
+ preferencesLookup[0].put(MavenPreferenceConstants.P_DEFAULT_RUNTIME, runtime.getName());
+ }
+ flush();
+ }
+
+ private void flush() {
+ try {
+ preferencesLookup[0].flush();
+ } catch(BackingStoreException ex) {
+ // TODO do nothing
+ }
+ }
+
+ public void setRuntimes(List<AbstractMavenRuntime> runtimes) {
+ removeRuntimePreferences();
+ Set<String> names = new HashSet<String>();
+ StringBuilder sb = new StringBuilder();
+ for(AbstractMavenRuntime runtime : runtimes) {
+ String name = runtime.getName();
+ if(!names.add(name)) {
+ throw new IllegalArgumentException();
+ }
+ if(runtime.isEditable()) {
+ if(sb.length() > 0) {
+ sb.append('|');
+ }
+ sb.append(name);
+ if(!runtime.isLegacy()) {
+ Preferences runtimeNode = getRuntimePreferences(name, true);
+ runtimeNode.put("type", getRuntimeType(runtime));
+ runtimeNode.put("location", runtime.getLocation());
+ String extensions = encodeClasspath(runtime.getExtensions());
+ if(extensions != null) {
+ runtimeNode.put("extensions", extensions);
+ } else {
+ runtimeNode.remove("extensions");
+ }
+ }
+ }
+ }
+ preferencesLookup[0].put(MavenPreferenceConstants.P_RUNTIMES, sb.toString());
+ flush();
+ }
+
+ private void removeRuntimePreferences() {
+ try {
+ if(preferencesLookup[0].nodeExists(MavenPreferenceConstants.P_RUNTIMES_NODE)) {
+ preferencesLookup[0].node(MavenPreferenceConstants.P_RUNTIMES_NODE).removeNode();
+ }
+ } catch(BackingStoreException ex) {
+ // assume the node does not exist
+ }
+ }
+
+ private String getRuntimeType(AbstractMavenRuntime runtime) {
+ if(runtime instanceof MavenExternalRuntime) {
+ return EXTERNAL;
+ } else if(runtime instanceof MavenWorkspaceRuntime) {
+ return WORKSPACE;
+ }
+ throw new IllegalArgumentException();
+ }
+
+ private Preferences getRuntimePreferences(String name, boolean create) {
+ Preferences runtimesNode = preferencesLookup[0].node(MavenPreferenceConstants.P_RUNTIMES_NODE);
+ try {
+ if(runtimesNode.nodeExists(name) || create) {
+ return runtimesNode.node(name);
+ }
+ } catch(BackingStoreException ex) {
+ // assume the node does not exist
+ }
+ return null;
+ }
+
+ private String encodeClasspath(List<ClasspathEntry> classpath) {
+ if(classpath == null || classpath.isEmpty()) {
+ return null;
+ }
+ StringBuilder sb = new StringBuilder();
+ for(ClasspathEntry cpe : classpath) {
+ if(sb.length() > 0) {
+ sb.append('|');
+ }
+ sb.append(cpe.toExternalForm());
+ }
+ return sb.toString();
+ }
+
+ private List<ClasspathEntry> decodeClasspath(String string) {
+ if(string == null || string.isEmpty()) {
+ return null;
+ }
+ List<ClasspathEntry> result = new ArrayList<ClasspathEntry>();
+ for(String entry : string.split("\\|")) {
+ ClasspathEntry decoded = ClasspathEntry.fromExternalForm(entry);
+ if(decoded != null) {
+ result.add(decoded);
+ }
+ }
+ return result;
+ }
+
+ public Map<String, AbstractMavenRuntime> getRuntimes() {
+ Map<String, AbstractMavenRuntime> runtimes = new LinkedHashMap<String, AbstractMavenRuntime>();
+ runtimes.put(EMBEDDED, new MavenEmbeddedRuntime());
+ runtimes.put(WORKSPACE, new DefaultWorkspaceRuntime());
+
+ String runtimesPreference = preferenceStore.get(MavenPreferenceConstants.P_RUNTIMES, null, preferencesLookup);
+ if(runtimesPreference != null && runtimesPreference.length() > 0) {
+ for(String name : runtimesPreference.split("\\|")) { //$NON-NLS-1$
+ Preferences preferences = getRuntimePreferences(name, false);
+ AbstractMavenRuntime runtime;
+ if(preferences == null) {
+ runtime = new MavenExternalRuntime(name);
+ } else {
+ runtime = createRuntime(name, preferences);
+ }
+ runtimes.put(runtime.getName(), runtime);
+ }
+ }
+
+ return runtimes;
+ }
+
+ private AbstractMavenRuntime createRuntime(String name, Preferences preferences) {
+ String location = preferences.get("location", null);
+ String type = preferences.get("type", EXTERNAL);
+ AbstractMavenRuntime runtime;
+ if(WORKSPACE.equals(type)) {
+ runtime = new MavenWorkspaceRuntime(name);
+ } else {
+ 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/launch/MavenWorkspaceRuntime.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenWorkspaceRuntime.java
index d631ce29..7af14883 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenWorkspaceRuntime.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenWorkspaceRuntime.java
@@ -26,7 +26,6 @@ import org.apache.maven.project.MavenProject;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.ArtifactKey;
import org.eclipse.m2e.core.embedder.IMavenLauncherConfiguration;
-import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
@@ -38,6 +37,7 @@ import org.eclipse.m2e.core.project.IMavenProjectRegistry;
* @author Igor Fedorenko
* @author Jason van Zyl
*/
+@SuppressWarnings("deprecation")
public class MavenWorkspaceRuntime extends AbstractMavenRuntime {
private static final ArtifactKey MAVEN_DISTRIBUTION = new ArtifactKey(
@@ -65,7 +65,7 @@ public class MavenWorkspaceRuntime extends AbstractMavenRuntime {
}
public String getLocation() {
- return MavenRuntimeManager.WORKSPACE;
+ return MavenRuntimeManagerImpl.WORKSPACE;
}
public String getSettings() {
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceConstants.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceConstants.java
index 8a94dfdc..7e545fae 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceConstants.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceConstants.java
@@ -12,7 +12,7 @@
package org.eclipse.m2e.core.internal.preferences;
-import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
+import org.eclipse.m2e.core.internal.launch.MavenRuntimeManagerImpl;
/**
@@ -64,10 +64,10 @@ public interface MavenPreferenceConstants {
/** boolean */
public static final String P_DISABLE_JDK_CHECK = PREFIX + "disableJdkCheck"; //$NON-NLS-1$
- /** String, list of configured maven installations separated by '|', see {@link MavenRuntimeManager} */
+ /** String, list of configured maven installations separated by '|', see {@link MavenRuntimeManagerImpl} */
public static final String P_RUNTIMES = PREFIX + "runtimes"; //$NON-NLS-1$
- /** Root node of extended maven installation attributes, see {@link MavenRuntimeManager} */
+ /** Root node of extended maven installation attributes, see {@link MavenRuntimeManagerImpl} */
public static final String P_RUNTIMES_NODE = PREFIX + "runtimesNodes"; //$NON-NLS-1$
/** String */
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 3b625bb5..0e753de1 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
@@ -26,9 +26,9 @@ import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.osgi.util.NLS;
import org.eclipse.m2e.actions.MavenLaunchConstants;
-import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.embedder.MavenRuntime;
-import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
+import org.eclipse.m2e.core.internal.launch.AbstractMavenRuntime;
+import org.eclipse.m2e.core.internal.launch.MavenRuntimeManagerImpl;
/**
@@ -36,12 +36,13 @@ import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
*
* @author Igor Fedorenko
*/
+@SuppressWarnings("restriction")
public class MavenLaunchUtils {
- public static MavenRuntime getMavenRuntime(ILaunchConfiguration configuration) throws CoreException {
- MavenRuntimeManager runtimeManager = MavenPlugin.getMavenRuntimeManager();
+ public static AbstractMavenRuntime getMavenRuntime(ILaunchConfiguration configuration) throws CoreException {
+ MavenRuntimeManagerImpl runtimeManager = MavenPluginActivator.getDefault().getMavenRuntimeManager();
String name = configuration.getAttribute(MavenLaunchConstants.ATTR_RUNTIME, ""); //$NON-NLS-1$
- MavenRuntime runtime = runtimeManager.getRuntimeByName(name);
+ AbstractMavenRuntime runtime = runtimeManager.getRuntimeByName(name);
if(runtime == null) {
throw new CoreException(new Status(IStatus.ERROR, MavenLaunchConstants.PLUGIN_ID, -1, //
NLS.bind(Messages.MavenLaunchUtils_error_no_maven_install, name), null));
@@ -49,7 +50,7 @@ public class MavenLaunchUtils {
return runtime;
}
- public static String getCliResolver(MavenRuntime runtime) throws CoreException {
+ public static String getCliResolver(AbstractMavenRuntime runtime) throws CoreException {
String jarname;
String runtimeVersion = runtime.getVersion();
if(runtimeVersion.startsWith("3.0")) { //$NON-NLS-1$
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 5779c3c7..ad631df1 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
@@ -37,8 +37,8 @@ import org.eclipse.jdt.launching.IVMRunner;
import org.eclipse.jdt.launching.VMRunnerConfiguration;
import org.eclipse.m2e.core.embedder.IMavenLauncherConfiguration;
-import org.eclipse.m2e.core.embedder.MavenRuntime;
import org.eclipse.m2e.core.internal.MavenPluginActivator;
+import org.eclipse.m2e.core.internal.launch.AbstractMavenRuntime;
import org.eclipse.m2e.core.internal.project.WorkspaceStateWriter;
@@ -60,10 +60,11 @@ import org.eclipse.m2e.core.internal.project.WorkspaceStateWriter;
*
* @since 1.4
*/
+@SuppressWarnings("restriction")
public class MavenRuntimeLaunchSupport {
private static final String LAUNCH_M2CONF_FILE = "org.eclipse.m2e.internal.launch.M2_CONF"; //$NON-NLS-1$
- private final MavenRuntime runtime;
+ private final AbstractMavenRuntime runtime;
private final MavenLauncherConfigurationHandler cwconf;
@@ -97,8 +98,8 @@ public class MavenRuntimeLaunchSupport {
}
}
- private MavenRuntimeLaunchSupport(MavenRuntime runtime, MavenLauncherConfigurationHandler cwconf, File cwconfFile,
- boolean resolveWorkspaceArtifacts) {
+ private MavenRuntimeLaunchSupport(AbstractMavenRuntime runtime, MavenLauncherConfigurationHandler cwconf,
+ File cwconfFile, boolean resolveWorkspaceArtifacts) {
this.runtime = runtime;
this.cwconf = cwconf;
this.cwconfFile = cwconfFile;
@@ -107,7 +108,7 @@ public class MavenRuntimeLaunchSupport {
public static MavenRuntimeLaunchSupport create(ILaunchConfiguration configuration, ILaunch launch,
IProgressMonitor monitor) throws CoreException {
- MavenRuntime runtime = MavenLaunchUtils.getMavenRuntime(configuration);
+ AbstractMavenRuntime runtime = MavenLaunchUtils.getMavenRuntime(configuration);
boolean resolveWorkspaceArtifacts = configuration.getAttribute(ATTR_WORKSPACE_RESOLUTION, false);
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 6050ccc9..3ba8ef39 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
@@ -41,7 +41,7 @@ import org.apache.maven.artifact.Artifact;
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.internal.launch.AbstractMavenRuntime;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
@@ -51,6 +51,7 @@ import org.eclipse.m2e.core.project.IMavenProjectFacade;
*
* @author Eugene Kuleshov
*/
+@SuppressWarnings({"restriction", "deprecation"})
public class MavenSourcePathComputer implements ISourcePathComputer {
public MavenSourcePathComputer() {
@@ -69,7 +70,7 @@ public class MavenSourcePathComputer implements ISourcePathComputer {
entries.add(jreEntry);
}
- MavenRuntime runtime = MavenLaunchUtils.getMavenRuntime(configuration);
+ AbstractMavenRuntime runtime = MavenLaunchUtils.getMavenRuntime(configuration);
IMavenLauncherConfiguration collector = new IMavenLauncherConfiguration() {
public void addArchiveEntry(String entry) throws CoreException {
addArchiveRuntimeClasspathEntry(entries, entry);
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java
index 0a07664d..a045f140 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java
@@ -38,12 +38,11 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.m2e.actions.MavenLaunchConstants;
-import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.embedder.MavenRuntime;
-import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.launch.AbstractMavenRuntime;
import org.eclipse.m2e.core.internal.launch.MavenEmbeddedRuntime;
import org.eclipse.m2e.core.internal.launch.MavenExternalRuntime;
+import org.eclipse.m2e.core.internal.launch.MavenRuntimeManagerImpl;
import org.eclipse.m2e.core.internal.launch.MavenWorkspaceRuntime;
@@ -55,8 +54,8 @@ public class MavenRuntimeSelector extends Composite {
ComboViewer runtimeComboViewer;
- private static MavenRuntimeManager getRuntimeManager() {
- return MavenPlugin.getMavenRuntimeManager();
+ private static MavenRuntimeManagerImpl getRuntimeManager() {
+ return MavenPluginActivator.getDefault().getMavenRuntimeManager();
}
public MavenRuntimeSelector(final Composite mainComposite) {
@@ -106,7 +105,7 @@ public class MavenRuntimeSelector extends Composite {
StringBuilder sb = new StringBuilder();
if(runtime.isLegacy()) {
- sb.append(MavenRuntimeManager.EXTERNAL).append(" ").append(runtime.toString());
+ sb.append(MavenRuntimeManagerImpl.EXTERNAL).append(" ").append(runtime.toString());
} else if(!runtime.isEditable()) {
sb.append(getType(runtime)).append(" (").append(runtime.toString()).append(')');
} else {
@@ -143,30 +142,30 @@ public class MavenRuntimeSelector extends Composite {
});
}
- protected String getType(MavenRuntime runtime) {
+ protected String getType(AbstractMavenRuntime runtime) {
if(runtime instanceof MavenEmbeddedRuntime) {
- return MavenRuntimeManager.EMBEDDED;
+ return MavenRuntimeManagerImpl.EMBEDDED;
} else if(runtime instanceof MavenWorkspaceRuntime) {
- return MavenRuntimeManager.WORKSPACE;
+ return MavenRuntimeManagerImpl.WORKSPACE;
} else if(runtime instanceof MavenExternalRuntime) {
- return MavenRuntimeManager.EXTERNAL;
+ return MavenRuntimeManagerImpl.EXTERNAL;
}
throw new IllegalArgumentException();
}
protected void setInput() {
- MavenRuntimeManager runtimeManager = getRuntimeManager();
+ MavenRuntimeManagerImpl runtimeManager = getRuntimeManager();
runtimeComboViewer.setInput(runtimeManager.getMavenRuntimes());
runtimeComboViewer.setSelection(new StructuredSelection(runtimeManager.getDefaultRuntime()));
}
- public void setSelectRuntime(MavenRuntime runtime) {
+ public void setSelectRuntime(AbstractMavenRuntime runtime) {
this.runtimeComboViewer.setSelection(new StructuredSelection(runtime));
}
- public MavenRuntime getSelectedRuntime() {
+ public AbstractMavenRuntime getSelectedRuntime() {
IStructuredSelection selection = (IStructuredSelection) runtimeComboViewer.getSelection();
- return (MavenRuntime) selection.getFirstElement();
+ return (AbstractMavenRuntime) selection.getFirstElement();
}
public void addSelectionChangedListener(ISelectionChangedListener listener) {
@@ -180,14 +179,14 @@ public class MavenRuntimeSelector extends Composite {
} catch(CoreException ex) {
// TODO log
}
- MavenRuntime runtime = getRuntimeManager().getRuntimeByName(name);
+ AbstractMavenRuntime runtime = getRuntimeManager().getRuntimeByName(name);
if(runtime != null) {
setSelectRuntime(runtime);
}
}
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
- MavenRuntime runtime = getSelectedRuntime();
+ AbstractMavenRuntime runtime = getSelectedRuntime();
configuration.setAttribute(MavenLaunchConstants.ATTR_RUNTIME, runtime.getName());
}
}

Back to the top