Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenArchetypesPreferencePage.java20
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java4
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizardParentPage.java24
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizard.java1
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java9
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypeParametersPage.java3
-rw-r--r--org.eclipse.m2e.core/META-INF/MANIFEST.MF20
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/MavenPlugin.java378
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/archetype/ArchetypeCatalogFactory.java5
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenModelManager.java3
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java403
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java13
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java3
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/AsyncFetcher.java3
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/NexusIndexManager.java13
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/LifecycleMappingFactory.java5
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/MarkerUtils.java5
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/LifecycleMappingConfiguration.java3
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java9
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/BasicProjectRegistry.java5
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryReader.java3
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java7
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java1
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java3
-rw-r--r--org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java1
-rw-r--r--org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java1
-rw-r--r--org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractLifecycleMappingTest.java5
-rw-r--r--org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java3
-rw-r--r--org.eclipse.m2e.usagedata/src/org/eclipse/m2e/internal/udc/MavenListener.java12
29 files changed, 530 insertions, 435 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenArchetypesPreferencePage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenArchetypesPreferencePage.java
index 3032c947..95d86455 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenArchetypesPreferencePage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenArchetypesPreferencePage.java
@@ -19,6 +19,9 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
@@ -31,12 +34,6 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
-import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.archetype.ArchetypeCatalogFactory;
-import org.eclipse.m2e.core.archetype.ArchetypeCatalogFactory.LocalCatalogFactory;
-import org.eclipse.m2e.core.archetype.ArchetypeCatalogFactory.RemoteCatalogFactory;
-import org.eclipse.m2e.core.archetype.ArchetypeManager;
-import org.eclipse.m2e.core.ui.internal.Messages;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -57,8 +54,13 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWebBrowser;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import org.eclipse.m2e.core.archetype.ArchetypeCatalogFactory;
+import org.eclipse.m2e.core.archetype.ArchetypeCatalogFactory.LocalCatalogFactory;
+import org.eclipse.m2e.core.archetype.ArchetypeCatalogFactory.RemoteCatalogFactory;
+import org.eclipse.m2e.core.archetype.ArchetypeManager;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
+import org.eclipse.m2e.core.ui.internal.Messages;
/**
@@ -77,7 +79,7 @@ public class MavenArchetypesPreferencePage extends PreferencePage implements IWo
public MavenArchetypesPreferencePage() {
setTitle(Messages.MavenArchetypesPreferencePage_title);
- this.archetypeManager = MavenPlugin.getDefault().getArchetypeManager();
+ this.archetypeManager = MavenPluginActivator.getDefault().getArchetypeManager();
}
protected void performDefaults() {
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
index d66c937c..3d05952d 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
@@ -44,6 +44,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.MavenModelManager;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.LifecycleMappingConfiguration;
import org.eclipse.m2e.core.project.AbstractProjectScanner;
import org.eclipse.m2e.core.project.LocalProjectScanner;
@@ -499,8 +500,7 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
protected AbstractProjectScanner<MavenProjectInfo> getProjectScanner() {
File root = workspaceRoot.getLocation().toFile();
- MavenPlugin mavenPlugin = MavenPlugin.getDefault();
- MavenModelManager modelManager = mavenPlugin.getMavenModelManager();
+ MavenModelManager modelManager = MavenPlugin.getDefault().getMavenModelManager();
if(showLocation) {
String location = rootDirectoryCombo.getText().trim();
if (location.length() > 0) {
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizardParentPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizardParentPage.java
index 896a1137..69712c1a 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizardParentPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenModuleWizardParentPage.java
@@ -13,7 +13,9 @@ package org.eclipse.m2e.core.ui.internal.wizards;
import java.util.List;
-import org.apache.maven.model.Model;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -24,11 +26,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.core.IMavenConstants;
-import org.eclipse.m2e.core.project.ProjectImportConfiguration;
-import org.eclipse.m2e.core.ui.internal.Messages;
-import org.eclipse.m2e.core.ui.internal.actions.SelectionUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -43,8 +40,14 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkingSet;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+import org.apache.maven.model.Model;
+
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.core.IMavenConstants;
+import org.eclipse.m2e.core.project.ProjectImportConfiguration;
+import org.eclipse.m2e.core.ui.internal.Messages;
+import org.eclipse.m2e.core.ui.internal.actions.SelectionUtil;
/**
@@ -224,13 +227,12 @@ public class MavenModuleWizardParentPage extends AbstractMavenWizardPage {
parentObject = pom;
parentContainer = pom.getParent();
- MavenPlugin plugin = MavenPlugin.getDefault();
try {
- parentModel = plugin.getMavenModelManager().readMavenModel(pom);
+ parentModel = MavenPlugin.getDefault().getMavenModelManager().readMavenModel(pom);
validateParent();
parentProjectText.setText(parentModel.getArtifactId());
} catch(CoreException e) {
- log.error("Error loading POM: " + e.getMessage(), e);
+ log.error("Error loading POM: " + e.getMessage(), e); //$NON-NLS-1$
}
}
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizard.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizard.java
index 60043690..b95f2c01 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizard.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenPomWizard.java
@@ -33,6 +33,7 @@ import org.eclipse.jface.wizard.Wizard;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.embedder.MavenModelManager;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.ui.internal.Messages;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.INewWizard;
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java
index fe02d90d..4d36d9d3 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypePage.java
@@ -61,6 +61,7 @@ import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.index.IMutableIndex;
import org.eclipse.m2e.core.index.IndexListener;
import org.eclipse.m2e.core.index.IndexManager;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.eclipse.m2e.core.repository.IRepository;
import org.eclipse.m2e.core.ui.internal.MavenImages;
@@ -246,7 +247,7 @@ public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage imp
}
});
- final ArchetypeManager archetypeManager = MavenPlugin.getDefault().getArchetypeManager();
+ final ArchetypeManager archetypeManager = MavenPluginActivator.getDefault().getArchetypeManager();
Collection<ArchetypeCatalogFactory> archetypeCatalogs = archetypeManager.getArchetypeCatalogs();
ArrayList allCatalogs = new ArrayList(archetypeManager.getArchetypeCatalogs());
allCatalogs.add(0, ALL_CATALOGS);
@@ -492,7 +493,7 @@ public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage imp
}
private List<Archetype> getAllArchetypes() {
- ArchetypeManager manager = MavenPlugin.getDefault().getArchetypeManager();
+ ArchetypeManager manager = MavenPluginActivator.getDefault().getArchetypeManager();
Collection<ArchetypeCatalogFactory> archetypeCatalogs = manager.getArchetypeCatalogs();
ArrayList<Archetype> list = new ArrayList<Archetype>();
@@ -611,7 +612,7 @@ public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage imp
super.setVisible(visible);
if(visible) {
- ArchetypeManager archetypeManager = MavenPlugin.getDefault().getArchetypeManager();
+ ArchetypeManager archetypeManager = MavenPluginActivator.getDefault().getArchetypeManager();
String catalogId = dialogSettings.get(KEY_CATALOG);
catalogFactory = null;
if(catalogId != null) {
@@ -743,7 +744,7 @@ public class MavenProjectWizardArchetypePage extends AbstractMavenWizardPage imp
archetype.setArtifactId(archetypeArtifactId);
archetype.setVersion(archetypeVersion);
archetype.setRepository(repositoryUrl);
- org.apache.maven.archetype.Archetype archetyper = MavenPlugin.getDefault().getArchetype();
+ org.apache.maven.archetype.Archetype archetyper = MavenPluginActivator.getDefault().getArchetype();
archetyper.updateLocalCatalog(archetype);
loadArchetypes(archetypeGroupId, archetypeArtifactId, archetypeVersion);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypeParametersPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypeParametersPage.java
index 9db58c02..8a6a99e9 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypeParametersPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenProjectWizardArchetypeParametersPage.java
@@ -39,6 +39,7 @@ import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMaven;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.eclipse.m2e.core.ui.internal.Messages;
import org.eclipse.m2e.core.ui.internal.components.TextComboBoxCellEditor;
@@ -392,7 +393,7 @@ public class MavenProjectWizardArchetypeParametersPage extends AbstractMavenWiza
List<ArtifactRepository> repositories = maven.getArtifactRepositories();
- ArchetypeArtifactManager aaMgr = MavenPlugin.getDefault().getArchetypeArtifactManager();
+ ArchetypeArtifactManager aaMgr = MavenPluginActivator.getDefault().getArchetypeArtifactManager();
if(aaMgr.isFileSetArchetype(groupId, artifactId, version, null, localRepository, repositories)) {
ArchetypeDescriptor descriptor = aaMgr.getFileSetArchetypeDescriptor(groupId, artifactId, version, null,
localRepository, repositories);
diff --git a/org.eclipse.m2e.core/META-INF/MANIFEST.MF b/org.eclipse.m2e.core/META-INF/MANIFEST.MF
index ead95b8a..21f9c3f4 100644
--- a/org.eclipse.m2e.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.m2e.core/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.m2e.core;singleton:=true
Bundle-Version: 0.13.0.qualifier
-Bundle-Activator: org.eclipse.m2e.core.MavenPlugin
+Bundle-Activator: org.eclipse.m2e.core.internal.MavenPluginActivator
Bundle-Vendor: %Bundle-Vendor
Bundle-Localization: plugin
Require-Bundle:
@@ -32,20 +32,20 @@ Export-Package: org.eclipse.m2e.core,
org.eclipse.m2e.core.core,
org.eclipse.m2e.core.embedder,
org.eclipse.m2e.core.index,
- org.eclipse.m2e.core.internal;x-friends:="org.eclipse.m2e.core.tests,org.eclipse.m2e.jdt",
+ org.eclipse.m2e.core.internal;x-internal:=true,
org.eclipse.m2e.core.internal.builder;x-internal:=true,
org.eclipse.m2e.core.internal.content;x-internal:=true,
- org.eclipse.m2e.core.internal.embedder;x-friends:="org.eclipse.m2e.core.tests",
- org.eclipse.m2e.core.internal.index;x-friends:="org.eclipse.m2e.core.tests,org.eclipse.m2e.editor,org.eclipse.m2e.editor.xml",
- org.eclipse.m2e.core.internal.lifecyclemapping;x-friends:="org.eclipse.m2e.tests,org.eclipse.m2e.editor.xml",
+ org.eclipse.m2e.core.internal.embedder;x-internal:=true,
+ org.eclipse.m2e.core.internal.index;x-internal:=true,
+ org.eclipse.m2e.core.internal.lifecyclemapping;x-internal:=true,
org.eclipse.m2e.core.internal.lifecyclemapping.discovery;x-internal:=true,
- org.eclipse.m2e.core.internal.lifecyclemapping.model,
+ org.eclipse.m2e.core.internal.lifecyclemapping.model;x-internal:=true,
org.eclipse.m2e.core.internal.lifecyclemapping.model.io.xpp3;x-internal:=true,
org.eclipse.m2e.core.internal.markers;x-internal:=true,
- org.eclipse.m2e.core.internal.preferences;x-friends:="org.eclipse.m2e.core.tests",
- org.eclipse.m2e.core.internal.project;x-friends:="org.eclipse.m2e.core.tests",
- org.eclipse.m2e.core.internal.project.registry;x-friends:="org.eclipse.m2e.core.tests",
- org.eclipse.m2e.core.internal.repository;x-friends:="org.eclipse.m2e.core.tests",
+ org.eclipse.m2e.core.internal.preferences;x-internal:=true,
+ org.eclipse.m2e.core.internal.project;x-internal:=true,
+ org.eclipse.m2e.core.internal.project.registry;x-internal:=true,
+ org.eclipse.m2e.core.internal.repository;x-internal:=true,
org.eclipse.m2e.core.jobs,
org.eclipse.m2e.core.lifecyclemapping.model,
org.eclipse.m2e.core.project,
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 4136ba9b..c5d6768f 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
@@ -11,396 +11,62 @@
package org.eclipse.m2e.core;
-import java.io.File;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-
-import org.codehaus.plexus.ContainerConfiguration;
-import org.codehaus.plexus.DefaultContainerConfiguration;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.MutablePlexusContainer;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.classworlds.ClassWorld;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-
-import org.apache.maven.archetype.Archetype;
-import org.apache.maven.archetype.common.ArchetypeArtifactManager;
-import org.apache.maven.archetype.source.ArchetypeDataSource;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.manager.WagonManager;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.resolver.ArtifactCollector;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.index.ArtifactContextProducer;
-import org.apache.maven.index.NexusIndexer;
-import org.apache.maven.index.updater.IndexUpdater;
-import org.apache.maven.plugin.LegacySupport;
-
-import org.sonatype.aether.RepositorySystem;
-
-import org.eclipse.m2e.core.archetype.ArchetypeCatalogFactory;
-import org.eclipse.m2e.core.archetype.ArchetypeManager;
-import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
import org.eclipse.m2e.core.embedder.MavenModelManager;
import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
import org.eclipse.m2e.core.index.IndexManager;
-import org.eclipse.m2e.core.internal.ExtensionReader;
-import org.eclipse.m2e.core.internal.embedder.MavenEmbeddedRuntime;
-import org.eclipse.m2e.core.internal.embedder.MavenImpl;
-import org.eclipse.m2e.core.internal.embedder.MavenWorkspaceRuntime;
-import org.eclipse.m2e.core.internal.index.IndexesExtensionReader;
-import org.eclipse.m2e.core.internal.index.IndexingTransferListener;
-import org.eclipse.m2e.core.internal.index.NexusIndexManager;
-import org.eclipse.m2e.core.internal.markers.IMavenMarkerManager;
-import org.eclipse.m2e.core.internal.markers.MavenMarkerManager;
-import org.eclipse.m2e.core.internal.preferences.MavenConfigurationImpl;
-import org.eclipse.m2e.core.internal.project.ProjectConfigurationManager;
-import org.eclipse.m2e.core.internal.project.WorkspaceStateWriter;
-import org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager;
-import org.eclipse.m2e.core.internal.project.registry.ProjectRegistryRefreshJob;
-import org.eclipse.m2e.core.internal.repository.RepositoryRegistry;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.project.IProjectConfigurationManager;
import org.eclipse.m2e.core.project.MavenProjectManager;
-import org.eclipse.m2e.core.project.MavenUpdateRequest;
import org.eclipse.m2e.core.repository.IRepositoryRegistry;
-/**
- * MavenPlugin main plug-in class.
- */
-public class MavenPlugin extends Plugin {
- private final Logger log = LoggerFactory.getLogger(MavenPlugin.class);
-
- public static final String PREFS_ARCHETYPES = "archetypesInfo.xml"; //$NON-NLS-1$
-
- // The shared instance
- private static MavenPlugin plugin;
-
- /**
- * General purpose plexus container. Contains components from maven embedder and all other bundles visible from this
- * bundle's classloader.
- */
- private MutablePlexusContainer plexus;
-
- private MavenModelManager modelManager;
-
- private NexusIndexManager indexManager;
-
- private BundleContext bundleContext;
-
- private MavenProjectManager projectManager;
+public final class MavenPlugin {
- private MavenRuntimeManager runtimeManager;
+ private static final MavenPlugin INSTANCE = new MavenPlugin();
- private ProjectConfigurationManager configurationManager;
+ private MavenPlugin() {
- private ProjectRegistryRefreshJob mavenBackgroundJob;
-
- private ArchetypeManager archetypeManager;
-
- private ProjectRegistryManager managerImpl;
-
- private IMavenMarkerManager mavenMarkerManager;
-
- private RepositoryRegistry repositoryRegistry;
-
- private String version = "0.0.0"; //$NON-NLS-1$
-
- private String qualifiedVersion = "0.0.0.qualifier"; //$NON-NLS-1$
-
- private IMavenConfiguration mavenConfiguration;
-
- private MavenImpl maven;
-
- public MavenPlugin() {
- plugin = this;
-
- if(Boolean.parseBoolean(Platform.getDebugOption(IMavenConstants.PLUGIN_ID + "/debug/initialization"))) { //$NON-NLS-1$
- System.err.println("### executing constructor " + IMavenConstants.PLUGIN_ID); //$NON-NLS-1$
- new Throwable().printStackTrace();
- }
- }
-
- public IMaven getMaven() {
- return maven;
}
/**
- * This method is called upon plug-in activation
- */
- public void start(final BundleContext context) throws Exception {
- super.start(context);
-
- if(Boolean.parseBoolean(Platform.getDebugOption(IMavenConstants.PLUGIN_ID + "/debug/initialization"))) { //$NON-NLS-1$
- System.err.println("### executing start() " + IMavenConstants.PLUGIN_ID); //$NON-NLS-1$
- new Throwable().printStackTrace();
- }
-
- this.bundleContext = context;
-
- try {
- this.qualifiedVersion = (String) getBundle().getHeaders().get(Constants.BUNDLE_VERSION);
- Version bundleVersion = Version.parseVersion(this.qualifiedVersion);
- this.version = bundleVersion.getMajor() + "." + bundleVersion.getMinor() + "." + bundleVersion.getMicro(); //$NON-NLS-1$ //$NON-NLS-2$
- } catch(IllegalArgumentException e) {
- // ignored
- }
-
- this.mavenConfiguration = new MavenConfigurationImpl();
-
- ClassLoader cl = MavenPlugin.class.getClassLoader();
- ContainerConfiguration cc = new DefaultContainerConfiguration().setClassWorld(new ClassWorld("plexus.core", cl)) //$NON-NLS-1$
- .setName("plexus"); //$NON-NLS-1$
- this.plexus = new DefaultPlexusContainer(cc);
-
- File stateLocationDir = getStateLocation().toFile();
-
- // TODO this is broken, need to make it lazy, otherwise we'll deadlock or timeout... or both
- this.archetypeManager = newArchetypeManager(stateLocationDir);
- try {
- this.archetypeManager.readCatalogs();
- } catch(Exception ex) {
- String msg = "Can't read archetype catalog configuration";
- log.error(msg, ex);
- }
-
- this.mavenMarkerManager = new MavenMarkerManager(mavenConfiguration);
-
- boolean updateProjectsOnStartup = mavenConfiguration.isUpdateProjectsOnStartup();
-
- ////////////////////////////////////////////////////////////////////////////////////////////////
-
- this.maven = new MavenImpl(mavenConfiguration);
-
- // TODO eagerly reads workspace state cache
- this.managerImpl = new ProjectRegistryManager(maven, stateLocationDir, !updateProjectsOnStartup /* readState */,
- mavenMarkerManager);
-
- this.mavenBackgroundJob = new ProjectRegistryRefreshJob(managerImpl, mavenConfiguration);
-
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- workspace.addResourceChangeListener(mavenBackgroundJob, IResourceChangeEvent.POST_CHANGE
- | IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE);
-
- this.projectManager = new MavenProjectManager(managerImpl, mavenBackgroundJob, stateLocationDir);
- this.projectManager.addMavenProjectChangedListener(new WorkspaceStateWriter(projectManager));
- if(updateProjectsOnStartup || managerImpl.getProjects().length == 0) {
- this.projectManager.refresh(new MavenUpdateRequest(workspace.getRoot().getProjects(), //
- mavenConfiguration.isOffline() /*offline*/, false /* updateSnapshots */));
- }
-
- this.modelManager = new MavenModelManager(maven, projectManager);
-
- this.runtimeManager = new MavenRuntimeManager();
- this.runtimeManager.setEmbeddedRuntime(new MavenEmbeddedRuntime(getBundleContext()));
- this.runtimeManager.setWorkspaceRuntime(new MavenWorkspaceRuntime(projectManager));
-
- this.configurationManager = new ProjectConfigurationManager(maven, managerImpl, modelManager,
- mavenMarkerManager, mavenConfiguration);
- this.projectManager.addMavenProjectChangedListener(this.configurationManager);
- workspace.addResourceChangeListener(configurationManager, IResourceChangeEvent.PRE_DELETE);
-
- //create repository registry
- this.repositoryRegistry = new RepositoryRegistry(maven, projectManager);
- this.maven.addSettingsChangeListener(repositoryRegistry);
- this.projectManager.addMavenProjectChangedListener(repositoryRegistry);
-
- //create the index manager
- this.indexManager = new NexusIndexManager(projectManager, repositoryRegistry, stateLocationDir);
- this.projectManager.addMavenProjectChangedListener(indexManager);
- this.maven.addLocalRepositoryListener(new IndexingTransferListener(indexManager));
- this.repositoryRegistry.addRepositoryIndexer(indexManager);
- this.repositoryRegistry.addRepositoryDiscoverer(new IndexesExtensionReader(indexManager));
-
- // fork repository registry update. must after index manager registered as a listener
- this.repositoryRegistry.updateRegistry();
- }
-
- private static ArchetypeManager newArchetypeManager(File stateLocationDir) {
- ArchetypeManager archetypeManager = new ArchetypeManager(new File(stateLocationDir, PREFS_ARCHETYPES));
- archetypeManager.addArchetypeCatalogFactory(new ArchetypeCatalogFactory.NexusIndexerCatalogFactory());
- archetypeManager.addArchetypeCatalogFactory(new ArchetypeCatalogFactory.InternalCatalogFactory());
- archetypeManager.addArchetypeCatalogFactory(new ArchetypeCatalogFactory.DefaultLocalCatalogFactory());
- for(ArchetypeCatalogFactory archetypeCatalogFactory : ExtensionReader.readArchetypeExtensions()) {
- archetypeManager.addArchetypeCatalogFactory(archetypeCatalogFactory);
- }
- return archetypeManager;
- }
-
- public PlexusContainer getPlexusContainer() {
- return plexus;
- }
-
- /**
- * This method is called when the plug-in is stopped
- */
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
-
- this.mavenBackgroundJob.cancel();
- try {
- this.mavenBackgroundJob.join();
- } catch(InterruptedException ex) {
- // ignored
- }
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- workspace.removeResourceChangeListener(this.mavenBackgroundJob);
- this.mavenBackgroundJob = null;
-
- this.projectManager.removeMavenProjectChangedListener(this.configurationManager);
- this.projectManager.removeMavenProjectChangedListener(indexManager);
- this.projectManager.removeMavenProjectChangedListener(repositoryRegistry);
- this.projectManager = null;
-
- this.plexus.dispose();
- this.maven.disposeContainer();
-
- workspace.removeResourceChangeListener(configurationManager);
- this.configurationManager = null;
-
- plugin = null;
- }
-
- /**
- * Returns the shared instance.
+ * @deprecated Use static getCOMPONENT methods instead
*/
public static MavenPlugin getDefault() {
- return plugin;
- }
-
- public MavenModelManager getMavenModelManager() {
- return this.modelManager;
- }
-
- public MavenProjectManager getMavenProjectManager() {
- return this.projectManager;
- }
-
- public ProjectRegistryManager getMavenProjectManagerImpl() {
- return this.managerImpl;
- }
-
- public IndexManager getIndexManager() {
- return this.indexManager;
- }
-
- public MavenRuntimeManager getMavenRuntimeManager() {
- return this.runtimeManager;
- }
-
- public ArchetypeManager getArchetypeManager() {
- return this.archetypeManager;
- }
-
- public IMavenMarkerManager getMavenMarkerManager() {
- return this.mavenMarkerManager;
+ return INSTANCE;
}
- public IMavenConfiguration getMavenConfiguration() {
- return this.mavenConfiguration;
- }
-
- public BundleContext getBundleContext() {
- return this.bundleContext;
- }
-
- public IProjectConfigurationManager getProjectConfigurationManager() {
- return configurationManager;
- }
-
- /** for use by unit tests */
- public ProjectRegistryRefreshJob getProjectManagerRefreshJob() {
- return mavenBackgroundJob;
- }
-
- private <C> C lookup(Class<C> role) {
- try {
- return plexus.lookup(role);
- } catch(ComponentLookupException ex) {
- throw new NoSuchComponentException(ex);
- }
- }
-
- private <T> T lookup(Class<T> role, String roleHint) {
- try {
- return plexus.lookup(role, roleHint);
- } catch(ComponentLookupException ex) {
- throw new NoSuchComponentException(ex);
- }
- }
-
- public static String getVersion() {
- return plugin.version;
- }
-
- public static String getQualifiedVersion() {
- return plugin.qualifiedVersion;
- }
-
- public IRepositoryRegistry getRepositoryRegistry() {
- return repositoryRegistry;
- }
-
- public Archetype getArchetype() {
- return lookup(Archetype.class);
- }
-
- public ArchetypeDataSource getArchetypeDataSource(String hint) {
- return lookup(ArchetypeDataSource.class, hint);
- }
-
- public ArchetypeArtifactManager getArchetypeArtifactManager() {
- return lookup(ArchetypeArtifactManager.class);
- }
-
- public IndexUpdater getIndexUpdater() {
- return lookup(IndexUpdater.class);
+ public IMaven getMaven() {
+ return MavenPluginActivator.getDefault().getMaven();
}
- public WagonManager getWagonManager() {
- return lookup(WagonManager.class);
+ public static MavenProjectManager getMavenProjectManager() {
+ return MavenPluginActivator.getDefault().getMavenProjectManager();
}
- public NexusIndexer getNexusIndexer() {
- return lookup(NexusIndexer.class);
+ public static IProjectConfigurationManager getProjectConfigurationManager() {
+ return MavenPluginActivator.getDefault().getProjectConfigurationManager();
}
- public ArtifactContextProducer getArtifactContextProducer() {
- return lookup(ArtifactContextProducer.class);
+ public static IRepositoryRegistry getRepositoryRegistry() {
+ return MavenPluginActivator.getDefault().getRepositoryRegistry();
}
- public ArtifactFactory getArtifactFactory() {
- return lookup(ArtifactFactory.class);
+ public static IndexManager getIndexManager() {
+ return MavenPluginActivator.getDefault().getIndexManager();
}
- public ArtifactMetadataSource getArtifactMetadataSource() {
- return lookup(ArtifactMetadataSource.class);
+ public static IMavenConfiguration getMavenConfiguration() {
+ return MavenPluginActivator.getDefault().getMavenConfiguration();
}
- public ArtifactCollector getArtifactCollector() {
- return lookup(ArtifactCollector.class);
+ public static MavenRuntimeManager getMavenRuntimeManager() {
+ return MavenPluginActivator.getDefault().getMavenRuntimeManager();
}
- public RepositorySystem getRepositorySystem() {
- return lookup(RepositorySystem.class);
+ public static MavenModelManager getMavenModelManager() {
+ return MavenPluginActivator.getDefault().getMavenModelManager();
}
- public MavenSession setSession(MavenSession session) {
- LegacySupport legacy = lookup(LegacySupport.class);
- MavenSession old = legacy.getSession();
- legacy.setSession(session);
- return old;
- }
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/archetype/ArchetypeCatalogFactory.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/archetype/ArchetypeCatalogFactory.java
index ca5a5100..c79707c8 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/archetype/ArchetypeCatalogFactory.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/archetype/ArchetypeCatalogFactory.java
@@ -28,6 +28,7 @@ import org.apache.maven.archetype.source.ArchetypeDataSourceException;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.core.IMavenConstants;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.Messages;
@@ -68,7 +69,7 @@ public abstract class ArchetypeCatalogFactory {
}
protected Archetype getArchetyper() {
- return MavenPlugin.getDefault().getArchetype();
+ return MavenPluginActivator.getDefault().getArchetype();
}
/**
@@ -83,7 +84,7 @@ public abstract class ArchetypeCatalogFactory {
public ArchetypeCatalog getArchetypeCatalog() throws CoreException {
try {
- ArchetypeDataSource source = MavenPlugin.getDefault().getArchetypeDataSource("nexus"); //$NON-NLS-1$
+ ArchetypeDataSource source = MavenPluginActivator.getDefault().getArchetypeDataSource("nexus"); //$NON-NLS-1$
return source.getArchetypeCatalog(new Properties());
} catch(ArchetypeDataSourceException ex) {
String msg = NLS.bind(Messages.ArchetypeCatalogFactory_error_missing_catalog, ex.getMessage());
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenModelManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenModelManager.java
index a5e2f411..bf6fa7d5 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenModelManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenModelManager.java
@@ -62,6 +62,7 @@ import org.sonatype.aether.util.graph.transformer.JavaEffectiveScopeCalculator;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.core.IMavenConstants;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.Messages;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.MavenProjectManager;
@@ -200,7 +201,7 @@ public class MavenModelManager {
DependencyNode node;
try {
- node = MavenPlugin.getDefault().getRepositorySystem().collectDependencies(session, request).getRoot();
+ node = MavenPluginActivator.getDefault().getRepositorySystem().collectDependencies(session, request).getRoot();
} catch(DependencyCollectionException ex) {
String msg = Messages.MavenModelManager_error_read;
log.error(msg, ex);
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
new file mode 100644
index 00000000..3c371130
--- /dev/null
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MavenPluginActivator.java
@@ -0,0 +1,403 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Sonatype, 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:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.m2e.core.internal;
+
+import java.io.File;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.DefaultContainerConfiguration;
+import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.MutablePlexusContainer;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.classworlds.ClassWorld;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+import org.apache.maven.archetype.Archetype;
+import org.apache.maven.archetype.common.ArchetypeArtifactManager;
+import org.apache.maven.archetype.source.ArchetypeDataSource;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.manager.WagonManager;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.resolver.ArtifactCollector;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.index.ArtifactContextProducer;
+import org.apache.maven.index.NexusIndexer;
+import org.apache.maven.index.updater.IndexUpdater;
+import org.apache.maven.plugin.LegacySupport;
+
+import org.sonatype.aether.RepositorySystem;
+
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.NoSuchComponentException;
+import org.eclipse.m2e.core.archetype.ArchetypeCatalogFactory;
+import org.eclipse.m2e.core.archetype.ArchetypeManager;
+import org.eclipse.m2e.core.core.IMavenConstants;
+import org.eclipse.m2e.core.embedder.IMaven;
+import org.eclipse.m2e.core.embedder.IMavenConfiguration;
+import org.eclipse.m2e.core.embedder.MavenModelManager;
+import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
+import org.eclipse.m2e.core.index.IndexManager;
+import org.eclipse.m2e.core.internal.embedder.MavenEmbeddedRuntime;
+import org.eclipse.m2e.core.internal.embedder.MavenImpl;
+import org.eclipse.m2e.core.internal.embedder.MavenWorkspaceRuntime;
+import org.eclipse.m2e.core.internal.index.IndexesExtensionReader;
+import org.eclipse.m2e.core.internal.index.IndexingTransferListener;
+import org.eclipse.m2e.core.internal.index.NexusIndexManager;
+import org.eclipse.m2e.core.internal.markers.IMavenMarkerManager;
+import org.eclipse.m2e.core.internal.markers.MavenMarkerManager;
+import org.eclipse.m2e.core.internal.preferences.MavenConfigurationImpl;
+import org.eclipse.m2e.core.internal.project.ProjectConfigurationManager;
+import org.eclipse.m2e.core.internal.project.WorkspaceStateWriter;
+import org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager;
+import org.eclipse.m2e.core.internal.project.registry.ProjectRegistryRefreshJob;
+import org.eclipse.m2e.core.internal.repository.RepositoryRegistry;
+import org.eclipse.m2e.core.project.IProjectConfigurationManager;
+import org.eclipse.m2e.core.project.MavenProjectManager;
+import org.eclipse.m2e.core.project.MavenUpdateRequest;
+import org.eclipse.m2e.core.repository.IRepositoryRegistry;
+
+public class MavenPluginActivator extends Plugin {
+ private final Logger log = LoggerFactory.getLogger(MavenPlugin.class);
+
+ public static final String PREFS_ARCHETYPES = "archetypesInfo.xml"; //$NON-NLS-1$
+
+ // The shared instance
+ private static MavenPluginActivator plugin;
+
+ /**
+ * General purpose plexus container. Contains components from maven embedder and all other bundles visible from this
+ * bundle's classloader.
+ */
+ private MutablePlexusContainer plexus;
+
+ private MavenModelManager modelManager;
+
+ private NexusIndexManager indexManager;
+
+ private BundleContext bundleContext;
+
+ private MavenProjectManager projectManager;
+
+ private MavenRuntimeManager runtimeManager;
+
+ private ProjectConfigurationManager configurationManager;
+
+ private ProjectRegistryRefreshJob mavenBackgroundJob;
+
+ private ArchetypeManager archetypeManager;
+
+ private ProjectRegistryManager managerImpl;
+
+ private IMavenMarkerManager mavenMarkerManager;
+
+ private RepositoryRegistry repositoryRegistry;
+
+ private String version = "0.0.0"; //$NON-NLS-1$
+
+ private String qualifiedVersion = "0.0.0.qualifier"; //$NON-NLS-1$
+
+ private IMavenConfiguration mavenConfiguration;
+
+ private MavenImpl maven;
+
+ public MavenPluginActivator() {
+ plugin = this;
+
+ if(Boolean.parseBoolean(Platform.getDebugOption(IMavenConstants.PLUGIN_ID + "/debug/initialization"))) { //$NON-NLS-1$
+ System.err.println("### executing constructor " + IMavenConstants.PLUGIN_ID); //$NON-NLS-1$
+ new Throwable().printStackTrace();
+ }
+ }
+
+ public IMaven getMaven() {
+ return maven;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+
+ if(Boolean.parseBoolean(Platform.getDebugOption(IMavenConstants.PLUGIN_ID + "/debug/initialization"))) { //$NON-NLS-1$
+ System.err.println("### executing start() " + IMavenConstants.PLUGIN_ID); //$NON-NLS-1$
+ new Throwable().printStackTrace();
+ }
+
+ this.bundleContext = context;
+
+ try {
+ this.qualifiedVersion = (String) getBundle().getHeaders().get(Constants.BUNDLE_VERSION);
+ Version bundleVersion = Version.parseVersion(this.qualifiedVersion);
+ this.version = bundleVersion.getMajor() + "." + bundleVersion.getMinor() + "." + bundleVersion.getMicro(); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch(IllegalArgumentException e) {
+ // ignored
+ }
+
+ this.mavenConfiguration = new MavenConfigurationImpl();
+
+ ClassLoader cl = MavenPlugin.class.getClassLoader();
+ ContainerConfiguration cc = new DefaultContainerConfiguration().setClassWorld(new ClassWorld("plexus.core", cl)) //$NON-NLS-1$
+ .setName("plexus"); //$NON-NLS-1$
+ this.plexus = new DefaultPlexusContainer(cc);
+
+ File stateLocationDir = getStateLocation().toFile();
+
+ // TODO this is broken, need to make it lazy, otherwise we'll deadlock or timeout... or both
+ this.archetypeManager = newArchetypeManager(stateLocationDir);
+ try {
+ this.archetypeManager.readCatalogs();
+ } catch(Exception ex) {
+ String msg = "Can't read archetype catalog configuration";
+ log.error(msg, ex);
+ }
+
+ this.mavenMarkerManager = new MavenMarkerManager(mavenConfiguration);
+
+ boolean updateProjectsOnStartup = mavenConfiguration.isUpdateProjectsOnStartup();
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+
+ this.maven = new MavenImpl(mavenConfiguration);
+
+ // TODO eagerly reads workspace state cache
+ this.managerImpl = new ProjectRegistryManager(maven, stateLocationDir, !updateProjectsOnStartup /* readState */,
+ mavenMarkerManager);
+
+ this.mavenBackgroundJob = new ProjectRegistryRefreshJob(managerImpl, mavenConfiguration);
+
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ workspace.addResourceChangeListener(mavenBackgroundJob, IResourceChangeEvent.POST_CHANGE
+ | IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE);
+
+ this.projectManager = new MavenProjectManager(managerImpl, mavenBackgroundJob, stateLocationDir);
+ this.projectManager.addMavenProjectChangedListener(new WorkspaceStateWriter(projectManager));
+ if(updateProjectsOnStartup || managerImpl.getProjects().length == 0) {
+ this.projectManager.refresh(new MavenUpdateRequest(workspace.getRoot().getProjects(), //
+ mavenConfiguration.isOffline() /*offline*/, false /* updateSnapshots */));
+ }
+
+ this.modelManager = new MavenModelManager(maven, projectManager);
+
+ this.runtimeManager = new MavenRuntimeManager();
+ this.runtimeManager.setEmbeddedRuntime(new MavenEmbeddedRuntime(getBundleContext()));
+ this.runtimeManager.setWorkspaceRuntime(new MavenWorkspaceRuntime(projectManager));
+
+ this.configurationManager = new ProjectConfigurationManager(maven, managerImpl, modelManager,
+ mavenMarkerManager, mavenConfiguration);
+ this.projectManager.addMavenProjectChangedListener(this.configurationManager);
+ workspace.addResourceChangeListener(configurationManager, IResourceChangeEvent.PRE_DELETE);
+
+ //create repository registry
+ this.repositoryRegistry = new RepositoryRegistry(maven, projectManager);
+ this.maven.addSettingsChangeListener(repositoryRegistry);
+ this.projectManager.addMavenProjectChangedListener(repositoryRegistry);
+
+ //create the index manager
+ this.indexManager = new NexusIndexManager(projectManager, repositoryRegistry, stateLocationDir);
+ this.projectManager.addMavenProjectChangedListener(indexManager);
+ this.maven.addLocalRepositoryListener(new IndexingTransferListener(indexManager));
+ this.repositoryRegistry.addRepositoryIndexer(indexManager);
+ this.repositoryRegistry.addRepositoryDiscoverer(new IndexesExtensionReader(indexManager));
+
+ // fork repository registry update. must after index manager registered as a listener
+ this.repositoryRegistry.updateRegistry();
+ }
+
+ private static ArchetypeManager newArchetypeManager(File stateLocationDir) {
+ ArchetypeManager archetypeManager = new ArchetypeManager(new File(stateLocationDir, PREFS_ARCHETYPES));
+ archetypeManager.addArchetypeCatalogFactory(new ArchetypeCatalogFactory.NexusIndexerCatalogFactory());
+ archetypeManager.addArchetypeCatalogFactory(new ArchetypeCatalogFactory.InternalCatalogFactory());
+ archetypeManager.addArchetypeCatalogFactory(new ArchetypeCatalogFactory.DefaultLocalCatalogFactory());
+ for(ArchetypeCatalogFactory archetypeCatalogFactory : ExtensionReader.readArchetypeExtensions()) {
+ archetypeManager.addArchetypeCatalogFactory(archetypeCatalogFactory);
+ }
+ return archetypeManager;
+ }
+
+ public PlexusContainer getPlexusContainer() {
+ return plexus;
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+
+ this.mavenBackgroundJob.cancel();
+ try {
+ this.mavenBackgroundJob.join();
+ } catch(InterruptedException ex) {
+ // ignored
+ }
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ workspace.removeResourceChangeListener(this.mavenBackgroundJob);
+ this.mavenBackgroundJob = null;
+
+ this.projectManager.removeMavenProjectChangedListener(this.configurationManager);
+ this.projectManager.removeMavenProjectChangedListener(indexManager);
+ this.projectManager.removeMavenProjectChangedListener(repositoryRegistry);
+ this.projectManager = null;
+
+ this.plexus.dispose();
+ this.maven.disposeContainer();
+
+ workspace.removeResourceChangeListener(configurationManager);
+ this.configurationManager = null;
+
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static MavenPluginActivator getDefault() {
+ return plugin;
+ }
+
+ public MavenModelManager getMavenModelManager() {
+ return this.modelManager;
+ }
+
+ public MavenProjectManager getMavenProjectManager() {
+ return this.projectManager;
+ }
+
+ public ProjectRegistryManager getMavenProjectManagerImpl() {
+ return this.managerImpl;
+ }
+
+ public IndexManager getIndexManager() {
+ return this.indexManager;
+ }
+
+ public MavenRuntimeManager getMavenRuntimeManager() {
+ return this.runtimeManager;
+ }
+
+ public ArchetypeManager getArchetypeManager() {
+ return this.archetypeManager;
+ }
+
+ public IMavenMarkerManager getMavenMarkerManager() {
+ return this.mavenMarkerManager;
+ }
+
+ public IMavenConfiguration getMavenConfiguration() {
+ return this.mavenConfiguration;
+ }
+
+ public BundleContext getBundleContext() {
+ return this.bundleContext;
+ }
+
+ public IProjectConfigurationManager getProjectConfigurationManager() {
+ return configurationManager;
+ }
+
+ /** for use by unit tests */
+ public ProjectRegistryRefreshJob getProjectManagerRefreshJob() {
+ return mavenBackgroundJob;
+ }
+
+ private <C> C lookup(Class<C> role) {
+ try {
+ return plexus.lookup(role);
+ } catch(ComponentLookupException ex) {
+ throw new NoSuchComponentException(ex);
+ }
+ }
+
+ private <T> T lookup(Class<T> role, String roleHint) {
+ try {
+ return plexus.lookup(role, roleHint);
+ } catch(ComponentLookupException ex) {
+ throw new NoSuchComponentException(ex);
+ }
+ }
+
+ public static String getVersion() {
+ return plugin.version;
+ }
+
+ public static String getQualifiedVersion() {
+ return plugin.qualifiedVersion;
+ }
+
+ public IRepositoryRegistry getRepositoryRegistry() {
+ return repositoryRegistry;
+ }
+
+ public Archetype getArchetype() {
+ return lookup(Archetype.class);
+ }
+
+ public ArchetypeDataSource getArchetypeDataSource(String hint) {
+ return lookup(ArchetypeDataSource.class, hint);
+ }
+
+ public ArchetypeArtifactManager getArchetypeArtifactManager() {
+ return lookup(ArchetypeArtifactManager.class);
+ }
+
+ public IndexUpdater getIndexUpdater() {
+ return lookup(IndexUpdater.class);
+ }
+
+ public WagonManager getWagonManager() {
+ return lookup(WagonManager.class);
+ }
+
+ public NexusIndexer getNexusIndexer() {
+ return lookup(NexusIndexer.class);
+ }
+
+ public ArtifactContextProducer getArtifactContextProducer() {
+ return lookup(ArtifactContextProducer.class);
+ }
+
+ public ArtifactFactory getArtifactFactory() {
+ return lookup(ArtifactFactory.class);
+ }
+
+ public ArtifactMetadataSource getArtifactMetadataSource() {
+ return lookup(ArtifactMetadataSource.class);
+ }
+
+ public ArtifactCollector getArtifactCollector() {
+ return lookup(ArtifactCollector.class);
+ }
+
+ public RepositorySystem getRepositorySystem() {
+ return lookup(RepositorySystem.class);
+ }
+
+ public MavenSession setSession(MavenSession session) {
+ LegacySupport legacy = lookup(LegacySupport.class);
+ MavenSession old = legacy.getSession();
+ legacy.setSession(session);
+ return old;
+ }
+
+}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java
index 7b04cb86..9f66f30b 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/builder/MavenBuilder.java
@@ -53,6 +53,7 @@ import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
import org.eclipse.m2e.core.internal.M2EUtils;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.markers.IMavenMarkerManager;
import org.eclipse.m2e.core.internal.markers.SourceLocation;
import org.eclipse.m2e.core.internal.markers.SourceLocationHelper;
@@ -68,7 +69,7 @@ import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
public class MavenBuilder extends IncrementalProjectBuilder {
private static Logger log = LoggerFactory.getLogger(MavenBuilder.class);
- public static boolean DEBUG = MavenPlugin.getDefault().isDebugging()
+ public static boolean DEBUG = MavenPluginActivator.getDefault().isDebugging()
& Boolean.parseBoolean(Platform.getDebugOption(IMavenConstants.PLUGIN_ID + "/debug/builder")); //$NON-NLS-1$
public static QualifiedName BUILD_CONTEXT_KEY = new QualifiedName(IMavenConstants.PLUGIN_ID, "BuildContext"); //$NON-NLS-1$
@@ -99,7 +100,7 @@ public class MavenBuilder extends IncrementalProjectBuilder {
MavenProjectManager projectManager = plugin.getMavenProjectManager();
IProjectConfigurationManager configurationManager = plugin.getProjectConfigurationManager();
IMavenConfiguration mavenConfiguration = MavenPlugin.getDefault().getMavenConfiguration();
- IMavenMarkerManager markerManager = plugin.getMavenMarkerManager();
+ IMavenMarkerManager markerManager = MavenPluginActivator.getDefault().getMavenMarkerManager();
markerManager.deleteMarkers(project, kind == FULL_BUILD, IMavenConstants.MARKER_BUILD_ID);
@@ -253,8 +254,7 @@ public class MavenBuilder extends IncrementalProjectBuilder {
private void processBuildResults(MavenProject mavenProject, MavenExecutionResult result,
AbstractEclipseBuildContext buildContext,
Map<Throwable, MojoExecutionKey> buildErrors) {
- MavenPlugin plugin = MavenPlugin.getDefault();
- IMavenMarkerManager markerManager = plugin.getMavenMarkerManager();
+ IMavenMarkerManager markerManager = MavenPluginActivator.getDefault().getMavenMarkerManager();
// Remove obsolete markers for problems reported by build participants
for(Entry<String, List<File>> entry : buildContext.getRemoveMessages().entrySet()) {
@@ -347,8 +347,7 @@ public class MavenBuilder extends IncrementalProjectBuilder {
msg = msg+": "+rootCause; //$NON-NLS-1$
}
- MavenPlugin plugin = MavenPlugin.getDefault();
- IMavenMarkerManager markerManager = plugin.getMavenMarkerManager();
+ IMavenMarkerManager markerManager = MavenPluginActivator.getDefault().getMavenMarkerManager();
markerManager.addMarker(getProject(), IMavenConstants.MARKER_BUILD_ID, msg, 1, IMarker.SEVERITY_ERROR);
}
@@ -376,7 +375,7 @@ public class MavenBuilder extends IncrementalProjectBuilder {
IProjectConfigurationManager configurationManager = plugin.getProjectConfigurationManager();
IProject project = getProject();
- IMavenMarkerManager markerManager = plugin.getMavenMarkerManager();
+ IMavenMarkerManager markerManager = MavenPluginActivator.getDefault().getMavenMarkerManager();
markerManager.deleteMarkers(project, IMavenConstants.MARKER_BUILD_ID);
if(!project.hasNature(IMavenConstants.NATURE_ID)) {
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
index 863e449a..4c9171d8 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
@@ -151,6 +151,7 @@ import org.eclipse.m2e.core.embedder.IMavenConfiguration;
import org.eclipse.m2e.core.embedder.IMavenConfigurationChangeListener;
import org.eclipse.m2e.core.embedder.ISettingsChangeListener;
import org.eclipse.m2e.core.embedder.MavenConfigurationChangeEvent;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.Messages;
import org.eclipse.m2e.core.internal.preferences.MavenPreferenceConstants;
@@ -203,7 +204,7 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
// logging
request.setTransferListener(createArtifactTransferListener(monitor));
- request.getUserProperties().put("m2e.version", MavenPlugin.getVersion()); //$NON-NLS-1$
+ request.getUserProperties().put("m2e.version", MavenPluginActivator.getVersion()); //$NON-NLS-1$
EnvironmentUtils.addEnvVars(request.getSystemProperties());
request.getSystemProperties().putAll(System.getProperties());
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/AsyncFetcher.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/AsyncFetcher.java
index 276476c2..1b9d6a0d 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/AsyncFetcher.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/AsyncFetcher.java
@@ -52,6 +52,7 @@ import org.apache.maven.wagon.proxy.ProxyUtils;
import org.apache.maven.wagon.repository.Repository;
import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.Messages;
@@ -138,7 +139,7 @@ public class AsyncFetcher extends AbstractResourceFetcher {
private String computeUserAgent() {
String osgiVersion = (String) Platform.getBundle("org.eclipse.osgi").getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION); //$NON-NLS-1$
- String m2eVersion = MavenPlugin.getQualifiedVersion();
+ String m2eVersion = MavenPluginActivator.getQualifiedVersion();
return "m2e/" + osgiVersion + "/" + m2eVersion; //$NON-NLS-1$
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/NexusIndexManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/NexusIndexManager.java
index b4da2f4b..e27fedf8 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/NexusIndexManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/NexusIndexManager.java
@@ -97,6 +97,7 @@ import org.eclipse.m2e.core.index.MatchTyped;
import org.eclipse.m2e.core.index.MatchTyped.MatchType;
import org.eclipse.m2e.core.index.SearchExpression;
import org.eclipse.m2e.core.index.SourcedSearchExpression;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.Messages;
import org.eclipse.m2e.core.internal.index.IndexUpdaterJob.IndexCommand;
import org.eclipse.m2e.core.internal.repository.IRepositoryIndexer;
@@ -178,7 +179,7 @@ public class NexusIndexManager implements IndexManager, IMavenProjectChangedList
this.baseIndexDir = new File(stateDir, "nexus"); //$NON-NLS-1$
this.maven = MavenPlugin.getDefault().getMaven();
- this.indexUpdater = MavenPlugin.getDefault().getIndexUpdater();
+ this.indexUpdater = MavenPluginActivator.getDefault().getIndexUpdater();
this.updaterJob = new IndexUpdaterJob(this);
@@ -192,7 +193,7 @@ public class NexusIndexManager implements IndexManager, IMavenProjectChangedList
private ArrayList<IndexCreator> getFullCreator() {
if(fullCreators == null) {
try {
- PlexusContainer container = MavenPlugin.getDefault().getPlexusContainer();
+ PlexusContainer container = MavenPluginActivator.getDefault().getPlexusContainer();
IndexCreator min = container.lookup(IndexCreator.class, MinimalArtifactInfoIndexCreator.ID);
IndexCreator mavenPlugin = container.lookup(IndexCreator.class, MavenPluginArtifactInfoIndexCreator.ID);
IndexCreator mavenArchetype = container.lookup(IndexCreator.class, MavenArchetypeArtifactInfoIndexCreator.ID);
@@ -214,7 +215,7 @@ public class NexusIndexManager implements IndexManager, IMavenProjectChangedList
private ArrayList<IndexCreator> getMinCreator() {
if(minCreators == null) {
try {
- PlexusContainer container = MavenPlugin.getDefault().getPlexusContainer();
+ PlexusContainer container = MavenPluginActivator.getDefault().getPlexusContainer();
IndexCreator min = container.lookup(IndexCreator.class, MinimalArtifactInfoIndexCreator.ID);
IndexCreator mavenArchetype = container.lookup(IndexCreator.class, MavenArchetypeArtifactInfoIndexCreator.ID);
minCreators = new ArrayList<IndexCreator>();
@@ -692,7 +693,7 @@ public class NexusIndexManager implements IndexManager, IMavenProjectChangedList
private NexusIndexer getIndexer() {
synchronized(indexerLock) {
if(indexer == null) {
- indexer = MavenPlugin.getDefault().getNexusIndexer();
+ indexer = MavenPluginActivator.getDefault().getNexusIndexer();
}
}
return indexer;
@@ -701,7 +702,7 @@ public class NexusIndexManager implements IndexManager, IMavenProjectChangedList
private ArtifactContextProducer getArtifactContextProducer() {
synchronized(contextProducerLock) {
if(artifactContextProducer == null) {
- artifactContextProducer = MavenPlugin.getDefault().getArtifactContextProducer();
+ artifactContextProducer = MavenPluginActivator.getDefault().getArtifactContextProducer();
}
}
return artifactContextProducer;
@@ -1172,7 +1173,7 @@ public class NexusIndexManager implements IndexManager, IMavenProjectChangedList
IndexUpdateRequest request = new IndexUpdateRequest(context, new AsyncFetcher(authenticationInfo, proxyInfo,
monitor));
File localRepo = repositoryRegistry.getLocalRepository().getBasedir();
- File indexCacheBasedir = new File(localRepo, ".cache/m2e/" + MavenPlugin.getVersion()).getCanonicalFile(); //$NON-NLS-1$
+ File indexCacheBasedir = new File(localRepo, ".cache/m2e/" + MavenPluginActivator.getVersion()).getCanonicalFile(); //$NON-NLS-1$
File indexCacheDir = new File(indexCacheBasedir, repository.getUid());
indexCacheDir.mkdirs();
request.setLocalIndexCacheDir(indexCacheDir);
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/LifecycleMappingFactory.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/LifecycleMappingFactory.java
index bd563373..b41b268d 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/LifecycleMappingFactory.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/LifecycleMappingFactory.java
@@ -65,6 +65,7 @@ import org.apache.maven.project.MavenProject;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.embedder.IMaven;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.Messages;
import org.eclipse.m2e.core.internal.embedder.MavenImpl;
import org.eclipse.m2e.core.internal.lifecyclemapping.model.LifecycleMappingMetadata;
@@ -644,7 +645,7 @@ public class LifecycleMappingFactory {
MavenPlugin plugin = MavenPlugin.getDefault();
configurator.setProjectManager(plugin.getMavenProjectManager());
configurator.setMavenConfiguration(plugin.getMavenConfiguration());
- configurator.setMarkerManager(plugin.getMavenMarkerManager());
+ configurator.setMarkerManager(MavenPluginActivator.getDefault().getMavenMarkerManager());
return configurator;
} catch(CoreException ex) {
@@ -912,7 +913,7 @@ public class LifecycleMappingFactory {
// XXX cache!
ArrayList<LifecycleMappingMetadataSource> sources = new ArrayList<LifecycleMappingMetadataSource>();
- BundleContext ctx = MavenPlugin.getDefault().getBundleContext();
+ BundleContext ctx = MavenPluginActivator.getDefault().getBundleContext();
Map<String, Bundle> bundles = new HashMap<String, Bundle>();
for(Bundle bundle : ctx.getBundles()) {
bundles.put(bundle.getSymbolicName(), bundle);
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/MarkerUtils.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/MarkerUtils.java
index 635eeddc..1e95c1f9 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/MarkerUtils.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/MarkerUtils.java
@@ -21,6 +21,7 @@ import org.eclipse.core.resources.IMarker;
import org.apache.maven.project.MavenProject;
import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
/**
* MarkerUtils
@@ -31,7 +32,7 @@ public class MarkerUtils {
private static Logger log = LoggerFactory.getLogger(MarkerUtils.class);
public static void decorateMarker(IMarker marker) {
- BundleContext context = MavenPlugin.getDefault().getBundleContext();
+ BundleContext context = MavenPluginActivator.getDefault().getBundleContext();
ServiceReference ref = context.getServiceReference(IMarkerLocationService.class.getName());
if(ref == null) {
log.warn("Could not find OSGI service for " + IMarkerLocationService.class.getName());
@@ -49,7 +50,7 @@ public class MarkerUtils {
public static void addEditorHintMarkers(IMavenMarkerManager markerManager, IFile pom, MavenProject mavenProject,
String type) {
- BundleContext context = MavenPlugin.getDefault().getBundleContext();
+ BundleContext context = MavenPluginActivator.getDefault().getBundleContext();
ServiceReference ref = context.getServiceReference(IEditorMarkerService.class.getName());
if (ref == null) {
log.warn("Could not find OSGI service for " + IEditorMarkerService.class.getName());
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/LifecycleMappingConfiguration.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/LifecycleMappingConfiguration.java
index abc5da39..2bead6c1 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/LifecycleMappingConfiguration.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/LifecycleMappingConfiguration.java
@@ -35,6 +35,7 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.apache.maven.plugin.MojoExecution;
import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.lifecyclemapping.model.PluginExecutionMetadata;
import org.eclipse.m2e.core.lifecyclemapping.model.IPluginExecutionMetadata;
import org.eclipse.m2e.core.lifecyclemapping.model.PluginExecutionAction;
@@ -128,7 +129,7 @@ public class LifecycleMappingConfiguration implements ILifecycleMappingConfigura
}
private static File getConfigurationFile(IProject project) {
- File stateLocationDir = MavenPlugin.getDefault().getStateLocation().toFile();
+ File stateLocationDir = MavenPluginActivator.getDefault().getStateLocation().toFile();
File configFile = new File(stateLocationDir, project.getName() + ".lifecyclemapping");
return configFile;
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java
index 658b8a89..40c9ce11 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java
@@ -75,6 +75,7 @@ import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
import org.eclipse.m2e.core.embedder.MavenModelManager;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.Messages;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory;
import org.eclipse.m2e.core.internal.markers.IMavenMarkerManager;
@@ -567,13 +568,13 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
MavenSession session = maven.createSession(maven.createExecutionRequest(monitor), null);
- MavenSession oldSession = MavenPlugin.getDefault().setSession(session);
+ MavenSession oldSession = MavenPluginActivator.getDefault().setSession(session);
ArchetypeGenerationResult result;
try {
result = getArchetyper().generateProjectFromArchetype(request);
} finally {
- MavenPlugin.getDefault().setSession(oldSession);
+ MavenPluginActivator.getDefault().setSession(oldSession);
}
Exception cause = result.getCause();
@@ -623,7 +624,7 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
IMavenConfiguration mavenConfiguration = MavenPlugin.getDefault().getMavenConfiguration();
if (!mavenConfiguration.isOffline()){
//Try to find the repository from remote catalog if needed
- final ArchetypeManager archetypeManager = MavenPlugin.getDefault().getArchetypeManager();
+ final ArchetypeManager archetypeManager = MavenPluginActivator.getDefault().getArchetypeManager();
RemoteCatalogFactory factory = archetypeManager.findParentCatalogFactory(a, RemoteCatalogFactory.class);
if (factory != null) {
//Grab the computed remote repository url
@@ -649,7 +650,7 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
}
private org.apache.maven.archetype.Archetype getArchetyper() {
- return MavenPlugin.getDefault().getArchetype();
+ return MavenPluginActivator.getDefault().getArchetype();
}
public Set<MavenProjectInfo> collectProjects(Collection<MavenProjectInfo> projects) {
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/BasicProjectRegistry.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/BasicProjectRegistry.java
index 5ab82a63..ea8acb34 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/BasicProjectRegistry.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/BasicProjectRegistry.java
@@ -21,6 +21,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.ArtifactKey;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
/**
@@ -32,7 +33,7 @@ abstract class BasicProjectRegistry implements Serializable {
private static final long serialVersionUID = 5542512601401896748L;
- private final String m2e_version = MavenPlugin.getQualifiedVersion();
+ private final String m2e_version = MavenPluginActivator.getQualifiedVersion();
/**
* Map<ArtifactKey, IPath> Maps ArtifactKey to full workspace IPath of the POM file that defines this artifact.
@@ -127,7 +128,7 @@ abstract class BasicProjectRegistry implements Serializable {
}
public boolean isValid() {
- return MavenPlugin.getQualifiedVersion().equals(m2e_version) //
+ return MavenPluginActivator.getQualifiedVersion().equals(m2e_version) //
&& workspaceArtifacts != null //
&& workspacePoms != null //
&& requiredCapabilities != null //
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryReader.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryReader.java
index 9af0cc86..156bf45d 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryReader.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryReader.java
@@ -39,6 +39,7 @@ import org.eclipse.osgi.service.resolver.VersionRange;
import org.codehaus.plexus.util.IOUtil;
import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
/**
@@ -110,7 +111,7 @@ public class ProjectRegistryReader {
private static synchronized PackageAdmin getPackageAdmin() {
// TODO inject dependencies already!
if(packageAdmin == null) {
- BundleContext context = MavenPlugin.getDefault().getBundleContext();
+ BundleContext context = MavenPluginActivator.getDefault().getBundleContext();
ServiceReference serviceReference = context.getServiceReference(PackageAdmin.class.getName());
packageAdmin = (PackageAdmin) context.getService(serviceReference);
}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java
index 0803243b..012121ed 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/dialogs/ManageDependenciesDialog.java
@@ -45,6 +45,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.ui.internal.dialogs.AbstractMavenDialog;
import org.eclipse.m2e.core.ui.internal.editing.PomEdits.CompoundOperation;
@@ -406,9 +407,9 @@ public class ManageDependenciesDialog extends AbstractMavenDialog {
model = MavenPlugin.getDefault().getMavenModelManager().readMavenModel(facade.getPom());
} catch(CoreException e) {
Object[] arguments = {facade.getPom(), e.getLocalizedMessage()};
- Status status = new Status(IStatus.ERROR, MavenEditorPlugin.PLUGIN_ID, NLS.bind(
- Messages.ManageDependenciesDialog_pomReadingError, arguments));
- MavenPlugin.getDefault().getLog().log(status);
+ String message = NLS.bind(Messages.ManageDependenciesDialog_pomReadingError, arguments);
+ Status status = new Status(IStatus.ERROR, MavenEditorPlugin.PLUGIN_ID, message);
+ LOG.info(message, e);
updateStatus(status);
error = true;
}
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
index f100b7b9..623b2057 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/pom/MavenPomEditor.java
@@ -55,6 +55,7 @@ import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.embedder.ArtifactKey;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.project.IMavenProjectChangedListener;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.MavenProjectChangedEvent;
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java
index 05ae523a..af133db2 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java
@@ -39,6 +39,7 @@ import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
import org.eclipse.m2e.core.embedder.IMavenLauncherConfiguration;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,7 +70,7 @@ public class MavenLaunchDelegate extends JavaLaunchDelegate implements MavenLaun
MavenLaunchUtils.addUserComponents(configuration, m2conf);
runtime.createLauncherConfiguration(m2conf, new NullProgressMonitor());
- File state = MavenPlugin.getDefault().getStateLocation().toFile();
+ File state = MavenPluginActivator.getDefault().getStateLocation().toFile();
try {
File dir = new File(state, "launches"); //$NON-NLS-1$
dir.mkdirs();
diff --git a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java
index 6bcc9a55..b06970e0 100644
--- a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java
+++ b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/exclude/ExcludeArtifactRefactoring.java
@@ -43,6 +43,7 @@ import org.eclipse.ltk.core.refactoring.Refactoring;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.ArtifactKey;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.ui.internal.editing.AddDependencyOperation;
import org.eclipse.m2e.core.ui.internal.editing.AddExclusionOperation;
diff --git a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java
index 4fff0d12..9a7692ef 100644
--- a/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java
+++ b/org.eclipse.m2e.scm/src/org/eclipse/m2e/scm/internal/wizards/MavenProjectCheckoutJob.java
@@ -38,6 +38,7 @@ import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.MavenModelManager;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.project.IMavenProjectImportResult;
import org.eclipse.m2e.core.project.LocalProjectScanner;
import org.eclipse.m2e.core.project.MavenProjectInfo;
diff --git a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractLifecycleMappingTest.java b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractLifecycleMappingTest.java
index 25a830e1..1e38d83e 100644
--- a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractLifecycleMappingTest.java
+++ b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractLifecycleMappingTest.java
@@ -34,6 +34,7 @@ import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.project.MavenProject;
import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory;
import org.eclipse.m2e.core.internal.lifecyclemapping.model.LifecycleMappingMetadataSource;
import org.eclipse.m2e.core.internal.project.registry.MavenProjectFacade;
@@ -106,8 +107,8 @@ public abstract class AbstractLifecycleMappingTest extends AbstractMavenProjectT
.calculateExecutionPlan(session, mavenProject, Arrays.asList(ProjectRegistryManager.LIFECYCLE_DEFAULT),
false, monitor).getMojoExecutions());
executionPlans.put(ProjectRegistryManager.LIFECYCLE_SITE, new ArrayList<MojoExecution>());
- MavenProjectFacade facade = new MavenProjectFacade(plugin.getMavenProjectManagerImpl(), pom, mavenProject,
- executionPlans, new ResolverConfiguration());
+ MavenProjectFacade facade = new MavenProjectFacade(MavenPluginActivator.getDefault().getMavenProjectManagerImpl(),
+ pom, mavenProject, executionPlans, new ResolverConfiguration());
return facade;
}
diff --git a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java
index 17eeb083..458c5ead 100644
--- a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java
+++ b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java
@@ -59,6 +59,7 @@ import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
import org.eclipse.m2e.core.embedder.MavenModelManager;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.embedder.MavenImpl;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory;
import org.eclipse.m2e.core.internal.project.registry.ProjectRegistryRefreshJob;
@@ -108,7 +109,7 @@ public abstract class AbstractMavenProjectTestCase extends TestCase {
plugin = MavenPlugin.getDefault();
- projectRefreshJob = plugin.getProjectManagerRefreshJob();
+ projectRefreshJob = MavenPluginActivator.getDefault().getProjectManagerRefreshJob();
projectRefreshJob.sleep();
downloadSourcesJob = ((BuildPathManager) MavenJdtPlugin.getDefault().getBuildpathManager()).getDownloadSourcesJob();
diff --git a/org.eclipse.m2e.usagedata/src/org/eclipse/m2e/internal/udc/MavenListener.java b/org.eclipse.m2e.usagedata/src/org/eclipse/m2e/internal/udc/MavenListener.java
index 2b1a6b8c..d1d43283 100644
--- a/org.eclipse.m2e.usagedata/src/org/eclipse/m2e/internal/udc/MavenListener.java
+++ b/org.eclipse.m2e.usagedata/src/org/eclipse/m2e/internal/udc/MavenListener.java
@@ -10,15 +10,17 @@
*******************************************************************************/
package org.eclipse.m2e.internal.udc;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
-import org.eclipse.m2e.core.MavenPlugin;
+
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.project.IMavenProjectChangedListener;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.MavenProjectChangedEvent;
import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/*
* Listens for Add project events and captures packaging and plugin types
@@ -40,7 +42,7 @@ public class MavenListener implements IMavenProjectChangedListener {
MavenListener(PomImportMonitor udcMonitor) {
this.udcMonitor = udcMonitor;
- MavenPlugin.getDefault().getMavenProjectManagerImpl().addMavenProjectChangedListener(this);
+ MavenPluginActivator.getDefault().getMavenProjectManagerImpl().addMavenProjectChangedListener(this);
}
public void mavenProjectChanged(MavenProjectChangedEvent[] events, IProgressMonitor monitor) {
@@ -77,6 +79,6 @@ public class MavenListener implements IMavenProjectChangedListener {
}
void stopListener() {
- MavenPlugin.getDefault().getMavenProjectManagerImpl().removeMavenProjectChangedListener(this);
+ MavenPluginActivator.getDefault().getMavenProjectManagerImpl().removeMavenProjectChangedListener(this);
}
}

Back to the top